[Q] Question from Python tutorial

William Park parkw at better.net
Thu Mar 1 21:05:58 CET 2001


On Thu, Mar 01, 2001 at 01:38:02PM -0600, Young-Jin Lee wrote:
> > > 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.

On my computer, it goes something like this:

>>> x.counter = 1
>>> while x.counter < 10:
...     x.counter = x.counter * 2
...
>>> print x.counter
16


---William Park, Open Geometry Consulting, Linux/Python, 8 CPUs.




More information about the Python-list mailing list