[Tutor] Re: Tutor digest, Vol 1 #1239 - 11 msgs

Jeff Shannon jeff@ccvcorp.com
Mon, 03 Dec 2001 10:43:54 -0800


>
>
> Message: 3
> Date: Mon, 3 Dec 2001 09:37:52 -0500 (EST)
> From:  <fleet@teachout.org>
> Reply-To:  <fleet@teachout.org>
> To:  <alan.gauld@bt.com>
> cc: python tutor list <tutor@python.org>
> Subject: RE: [Tutor] class data
>
> Everything went fine until -
>
> >>> for e in book:
> ...    e.saveme('book.txt')
> ...
> Traceback (innermost last):
>   File "<stdin>", line 2, in ?
>   File "<stdin>", line 8, in saveme
> TypeError: read-only buffer, tuple
>
>                                 - fleet -
>
> On Mon, 3 Dec 2001 alan.gauld@bt.com wrote:
> > book = []
> > for i in range(10):
> >    book.append(Entry('al','1234','ag.co.com')

The problem is that this line is short a paren---

... book.append( Entry('al','1234','ag.co.com') ) # <-- two of each paren

Without that closing paren, the interpreter was trying to read *everything* after that as part of a
tuple... with obvious problems.  :)

(I don't know if IDLE does this, but PythonWin will automatically highlight matching parens--this
is a *very* handy little feature.)

Jeff Shannon
Technician/Programmer
Credit International