| | |
Newbie With Function Trouble
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: May 2009
Posts: 2
Reputation:
Solved Threads: 0
im a first time programmer learning python from books and so far ive learnt how to create and define functions but once ive saved them, im not sure how to call them so that i can use them. it works fine when i type in the function name but only if im in the same window that i wrote the function in. what i cant do is use IDLE to write the function, save it, and then call it in a completly new window. help, thx, toby.
oh and maybe i should mention im only 15, so if this is a really stupid question thats probably why.
oh and maybe i should mention im only 15, so if this is a really stupid question thats probably why.
Last edited by pydude94; May 29th, 2009 at 8:51 pm.
•
•
Join Date: Jun 2008
Posts: 128
Reputation:
Solved Threads: 31
Let me give you an example.
There are two files. The first is compute.py and has the code:
And there is your program, main.py
The question is, how will python know where to find this compute module?
The answer is here.
So in the most simple case, if you put these two files into the same directory, you go there, and run python main.py , then it will work.
There are two files. The first is compute.py and has the code:
python Syntax (Toggle Plain Text)
def sumup(a,b): return a+b
And there is your program, main.py
python Syntax (Toggle Plain Text)
import compute print compute.sumup(2,3)
The question is, how will python know where to find this compute module?
The answer is here.
So in the most simple case, if you put these two files into the same directory, you go there, and run python main.py , then it will work.
![]() |
Similar Threads
- Help with my first step on Php (PHP)
- Read delimited file (C++)
- bool function problems! (C++)
- newbie help about function (C++)
- Newbie type trouble (Python)
- Delete function for linked list (C++)
- Pointers to struct (C++)
- Windows media player (Windows NT / 2000 / XP)
- Bookmarker.gen can't get rid of! (Viruses, Spyware and other Nasties)
Other Threads in the Python Forum
- Previous Thread: Web Spider Help
- Next Thread: Parsing text from a SMI file and writing to a file
| Thread Tools | Search this Thread |
Tag cloud for Python
accessdenied apache application argv beginner book change code color converter dictionary dynamic edit editing enter examples excel file filename float format ftp function gui homework import inches input java keyboard lapse library line lines linux list lists loop microphone mouse movingimageswithpygame mysql newb number numbers numeric output parameters parsing path phonebook port prime program programming projects py2exe pygame pyopengl pyqt python random recursion recursive redirect remote reverse scrolledtext server session simple smtp software sprite ssh statictext string strings syntax table tennis terminal text thread threading time tkinter tlapse trick tuple tutorial ubuntu unicode unit urllib urllib2 variable windows wordgame wxpython





