python script get defined function by name
If I define a function inside a PythonScript, can I get that function by name somehow using getattr() or some other way? As in... #PythonScript def abc(): pass abc = getattr(======, 'abc') #end what would I use for ====== ? _________________________________________________________________ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx
Lee Harr wrote:
If I define a function inside a PythonScript, can I get that function by name somehow using getattr() or some other way?
As in...
#PythonScript
def abc(): pass
abc = getattr(======, 'abc')
In Python, a 'def' statement binds the newly created function to a name in the current namespace. Your definition acts a little bit like the (totally imaginary) code: abc = make_function('abc', (), 'pass') ...so 'abc' already exists, there's no need to "get" it. Example: def abc(x): return x + 1 y = abc(1) Cheers, Evan @ 4-am
participants (2)
-
Evan Simpson -
Lee Harr