[Tutor] RE: Newbie problem with TypeError
jsoons at juilliard.edu
Mon Nov 17 12:13:18 EST 2003
>I am completely baffled by this TypeError.
>The program is 617 lines so I am just showing the relevant part.
>def newpage(words) :
> PDF_begin_page(pdf, WIDTH, HEIGHT)
> PDF_setfont(pdf, font0, 14)
> PDF_set_text_pos(pdf, INCH, 704)
> PDF_show(pdf, last + ", " + first)
> PDF_set_text_pos(pdf, INCH, 690)
I just took Danny Yoo's advice and changed this to:
def mklines(field) :
if len(field) < 4 :
words = field.split(" ")
while len(words) > 1 :
line = ""
list(words) #definitely a list
while (len(line) < 60) and len(words) > 1 :
line = line + " " + words
if len(words) > 0 :
if PDF_get_value(pdf, "texty", 0) < INCH :
txt = string.joinfields(words, " ") #new variable???!!!
newpage(txt) #since the old one got stuck as a tuple.
if len(words) == 1 : #and couldn't be made into a string
PDF_continue_text(pdf, " " + words)
No error now but I don't know why I can't reuse the 'words' variable and cast it to string.
I can live with that tho since it now runs.
>Traceback (most recent call last):
> File "./parseapps.py", line 174, in ?
> File "./parseapps.py", line 50, in mklines
> TypeError: object doesn't support item deletion
More information about the Tutor