Calling "def" functions from another file.
Bruno Desthuilliers
bdesth.quelquechose at free.quelquepart.fr
Wed Aug 13 12:11:20 EDT 2008
frankrentef a écrit :
> Newbie here....
>
> I'm writing a Python program that has "def" functionality
functions
> growing in
> leaps and bounds. I'm a newbie to Python so be detailed. Is there a
> way to create a py file with all the "def's" listed and just call them
> from the "program" py file?
yes. Put all your functions in a .py file, and import that file from the
main 'program' file.
> How would I do this?
All this is in the FineManual(tm), here:
http://docs.python.org/tut/node8.html
I strongly suggest you read this first, experiment a bit, then come back
here if you have any trouble or question.
> Say my "def" py
> file was named def.py
Bad name. 'def' is a reserved word, so you can't name a module (a .py
file) that way.
More information about the Python-list
mailing list