Function definition

faulkner faulkner612 at comcast.net
Mon Jun 19 19:16:15 EDT 2006


no.
python is not C. python is interpreted, not compiled, so if you want a
function to exist when you call it, you need to define it before you
call it.
it isn't clunky, it's just how it's done.
if you want to define a 'main' function at the top of your
script/module, go for it. then you can use this:
if __name__ == '__main__': sys.exit(main(*sys.argv[1:]))

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?
> 
> Thanks.
> Aaron




More information about the Python-list mailing list