[Q] Question from Python tutorial
Jay O'Connor
joconnor at cybermesa.com
Thu Mar 1 14:35:14 EST 2001
Young-Jin Lee wrote:
> Hi, I have a question from Python tutorial.
> The code segment in the page 60 (chapter 9. classes) is not executed.
> I don't know what I did wrong. Here is the code and the error I got.
>
> class MyClass:
> "A simple example class"
> i = 12345
> def f( x ):
> return 'hello world'
>
> x = MyClass()
>
> x.counter = 1
> while x.counter < 10:
> x.counter = x.counter * 2
> print x.counter
> ^
> SyntaxError: invalid syntax
>
> There is no typo, I have no idea of where this SyntaxError came from.
>
> Thanks in advance. Any comment would be greatly appreciated.
You probably cut and pasted the code from the tutorial. When I cut and
pasted your code into IDLE, I got the same error. When I manyually typed
the code, it works fine. My guess is that the cut and paste didn't paste
properly and the interactive interpreter didn't make the right break
between the 2 and the word print
--
Jay O'Connor
joconnor at cybermesa.com
http://www.cybermesa.com/~joconnor
Python Language Forum -
http://pub1.ezboard.com/fobjectorienteddevelopmentpython
More information about the Python-list
mailing list