aarondesk wrote:

> I have a little .py file that has the format:
> 
> 
> def fxn(a):
>     do stuff
> 
> other stuff
> ...
> r = fxn(a)
> ....
> 
> 
> Now I've tried putting the function declaration after the call but the
> program wouldn't work. Is there anyway to put function declarations at
> the end of the program, rather than putting them at the beginning,
> which is rather clunky?
> 

How about putting your main program code inside another function called 
something like 'main'? Then it can appear wherever you like. All you need 
at the end of the file then is:

if __name__=='__main__':
   main()

This also means you can reuse the functions with different main code simply 
by importing them from another file.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to