How to run scripts from idle
Shae Erisson
shapr at uab.edu
Mon Jun 5 09:34:45 EDT 2000
Tim Gahnström wrote:
>
> When I start idle and have the window called
> Pyton Shell
> starting with
> >>> I canot load scripts I have created.
>
> I can type >>>Print "Hi"
> but If I create a file named hi.py containing print "hi"
>
> And try to run it I just gett the error message
> ---
> Traceback (innermost last):
> File "<pyshell#5>", line 1, in ?
> test
> NameError: test
> ---
> It seems like idle wont find my scripts but I have tried put them al over
> the computer :-) and the path seems correct.
>
> Tim Gahnström
You need to 'import hi' to get the file hi.py to run.
if you define a function inside the hi.py file like:
def printhi():
print 'hi'
then you do this:
>>import hi
>>hi.printhi()
hi
--
sHae mAtijs eRisson (sHae at wEbwitchEs.coM) gEnius fOr hIre
bRing mE fIve sQuirrels aNd nO oNe wIll gEt hUrt
13:00pm up 1 season, 1 squirrel, load average: 1+1j 0.5+2j 0.2+0.5j
More information about the Python-list
mailing list