15 Oct
2002
15 Oct
'02
5:21 p.m.
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