[Tutor] running scripts in IDLE

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Thu, 7 Mar 2002 10:12:41 -0800 (PST)


On Thu, 7 Mar 2002, Ron Nixon wrote:

> I have this script
> 
> myfile = open("c:/menu.txt", 'r')
>     for line in myfile.readlines():
>         print line
>      myfile.close()

One thing about Python is that whitespace indentation is signficiant: you
probably meant:

###
myfile = open("c:/menu.txt", "r")
for line in myfile.readlines():
    print line
myfile.close()
###

That is, we indent only when we start off a new block.  It seems a little
strict at first, but if you're using IDLE, you can press the Tab button,
and it should jump to the next indentation level automatically.

Good luck!