[Q] Question from Python tutorial

Young-Jin Lee ylee12 at uiuc.edu
Thu Mar 1 14:20:25 EST 2001


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.

Young-Jin





More information about the Python-list mailing list