late bindings ???
Christopher A. Craig
list-python at ccraig.org
Tue Dec 3 08:25:45 EST 2002
"Alfredo P. Ricafort" <alpot at mylinuxsite.com> writes:
> Option 1 seems to have a limitation that you cannot call functions in
> a class ??? On the other hand, option 2 can only call functions in a
> class ???
Well, option 1 has the limitation that you can't set your names
outside the global namespace (because globals is the global namespace,
not a local namespace). You could get around that with option 3:
---------
def func1(*args):
pass
t = "func1"
eval(t)(1, 2)
---------
Which is the simplest method I've seen. Again, I don't know why you
want to do this, and you should really find another way. This is
_very_ bad practice.
--
Christopher A. Craig <list-python at ccraig.org>
"I don't know of any version of Unix on Intel that is not technically superior
to Windows NT." -- Nicholas Petreley (InfoWorld Columnist)
More information about the Python-list
mailing list