Calling "def" functions from another file.

Terry Reedy tjreedy at
Wed Aug 13 22:22:09 CEST 2008

frankrentef 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 and the program file was named ""

This is what all the modules in the standard library are about. (in same directory as or in sys.path directory
def a(b,c):
   return b*c-(b+c)//2
import func
print(func.a(2,4)) #3.0

# should print 5

More information about the Python-list mailing list