[Tutor] calling user defined function

spir denis.spir at free.fr
Sun Feb 22 23:23:26 CET 2009


Le Sun, 22 Feb 2009 22:21:22 +0100,
roberto <roberto03 at gmail.com> s'exprima ainsi:

> 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 ?

I guess what you mean is how to run your program?
If you write it inside the editor (as opposed to the interactive window where you get the prompt), then all you need is save (where ever you like it) and run (menu or F5). The program's output, if any, will then happen inside the interactive window.

You can also "run" a program or module by importing it from inside the interactive window, using
>>> import filenamewithoutdotpy
Further runs/imports during the same session must however be expressed with
>>> reload(filenamewithoutdotpy)

Denis
------
la vita e estrany


More information about the Tutor mailing list