Must function defs appear earlier than calls?

John Roth newsgroups at jhrothjr.com
Mon May 3 21:13:51 EDT 2004


<SeeBelow at SeeBelow.Nut> wrote in message news:4096E9F8.38ABF26D at shaw.ca...
> Must function defs appear earlier in a file than use of their name?

No. Function definitions must be executed before they
are called, but they don't have to be before their
calls.

The reason for this is that it's the execution of the function
definition at run time that binds the function to the name in
the dictionary, and that's where it has to be to be executed.

> If so, is there some way around this?  It's creating a puzzle for me.

Possibly you could say a bit more about what you're
trying to do that's causing some perplexity?

John Roth
>
> Mitchell Timin





More information about the Python-list mailing list