Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old August 13th, 2008, 05:45 PM
frankrentef
Guest
 
Posts: n/a
Default Calling "def" functions from another file.

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
  #2  
Old August 13th, 2008, 09:25 PM
Terry Reedy
Guest
 
Posts: n/a
Default Re: Calling "def" functions from another file.



frankrentef wrote:
Quote:
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"
This is what all the modules in the standard library are about.

func.py (in same directory as prog.py or in sys.path directory
----------------
def a(b,c):
return b*c-(b+c)//2

prog.py
------------------
import func
print(func.a(2,4)) #3.0

# should print 5

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles