[Q] Question from Python tutorial

Richie Sum rs at richsomerfield.com
Thu Mar 1 15:11:34 EST 2001


If u cut n paste your code in courier font then it is much easier to spot
possible problems.
Maybe a missing / extra space character?

RS


Young-Jin Lee <ylee12 at uiuc.edu> wrote in message
news:hxxn6.6969$dL4.91744 at vixen.cso.uiuc.edu...
> I typed them manually. I dind't copy and paste.
>
> "Jay O'Connor" <joconnor at cybermesa.com> wrote in message
> news:3A9EA472.F15AF847 at cybermesa.com...
> >
> >
> > 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