On Sun, 22 Feb 2009 22:21:22 +0100, roberto wrote:

> hello
> i have a question which i didn't solved yet: i can define a function
> using the text editor provided by IDLE 3.0; then i'd like to call this
> function from the python prompt
> 
> but when i try to do it, python warns me that function doesn't exist of
> course if i define the function directly using the >>> prompt, after
> that everything is fine
> 
> may you tell me where i have to save the file that defines the function
> is order to use it later ?
> is it a problem of path ?
> 
> my version of python is 3.0, OS windows xp
> 
> thank you very much in advance

or you can also run your module with -i (interactive) argument, which 
means to put you into the interactive mode after the module ends.

# mycode.py
def foo(): 
    print 'bar'
print 'output of program (if any)'

# then run this in your shell:
$ python -i mycode.py
output of program (if any)
>>> foo()
bar

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to