[Tutor] Python Versions

Alan Gauld alan.gauld at btinternet.com
Wed Dec 12 23:04:59 CET 2007


"earlylight publishing" <earlylightpublishing at yahoo.com> wrote

>I have the latest python version too when I first started "A Byte of 
>Python"
> my code wouldn't work either.  My problem was that I was programming
> in the shell (the screen with the three '>>>' on it).  I found when 
> I wrote
> the examples in a new window (cntrl+N) they all worked as 
> advertized.

Unless you are doing some strange GUI type things it should work at
the >>> prompt too. (Sometimes you need an extra line - that could
fox beginners I suspect, if his examples contain multiple statements)

> He never mentions that you need to use an 'editing window'
> (I think it's called).  I just stumbled across the fact.

You shouldn't need to use an editing window, but the >>> prompt
does execute each line 9or block) in turn thus:

x=0
for n in range(5):
    x = n+x
print x

looks like this in IDLE:

>>> x=0
>>> for n in range(5):
    x = n+x
                                            <--Extra line here!
>>> print x
10
>>>

Is that the kind of thing you are seeing?


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 




More information about the Tutor mailing list