Function declarations

Moshe Zadka moshez at zadka.site.co.il
Mon Nov 20 21:55:18 EST 2000


> Is it possible to obtain a reference to a function before it has been
> 'def'ined?

No.

> eg:
> 
> do_something(my_func)
> 
> def my_func():
>     blahblah...

That won't work.

However, note that the similar

def main():
	do_something(my_func)

def my_func():
	pass

main()

Does work. It's frequently enough.

> I find Python's "def is an executable statement" very irritating...

You'll probably have to live with it. It's not an incidental feature 
(like the type/class dichotomy), but the heart and soul of Python.

-- 
Moshe Zadka <sig at zadka.site.co.il>
This is a signature anti-virus. 
Please stop the spread of signature viruses!




More information about the Python-list mailing list