Calling "def" functions from another file.

Benjamin Kaplan benjamin.kaplan at case.edu
Wed Aug 13 13:00:48 EDT 2008


On Wed, Aug 13, 2008 at 12:37 PM, frankrentef <frankrentef at yahoo.com> wrote:

> Newbie here....
>
> I'm writing a Python program that has "def" functionality 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?  How would I do this?  Say my "def" py
> file was named def.py and the program file was named "program.py"
>
> THNX


1. Don't call the file def.py. def is a keyword, so you'll confuse the
interpreter.
2. Read the tutorial. "defs" are really called functions and "py files" are
referred to as modules.

Read the part of the tutorial pertaining to modules. It will answer your
question.

http://docs.python.org/tut/tut.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080813/bb9317ea/attachment-0001.html>


More information about the Python-list mailing list