[Tutor] Newbie problem with TypeError
Alan Gauld
alan.gauld at blueyonder.co.uk
Mon Nov 17 12:31:35 EST 2003
> I am completely baffled by this TypeError.
I'm not sure this will help but...
def mklines(field) :
if len(field) < 4 :
return
words = field.split(" ")
while len(words) > 1 :
line = ""
list(words) #definitely a list
list returns a new list it doesn't convert the argument.
I think you want
words = list(words)
if PDF_get_value(pdf, "texty", 0) < INCH :
words = string.joinfields(words, " ")
str(words) #newpage() requires string
argument
Similarly str just returns a copy it does not change
the original. You probably want
words = str(words)
or just
newpage(str(words))
File "./parseapps.py", line 50, in mklines
del(words[0])
TypeError: object doesn't support item deletion
But why you get that I'm not sure, you appear to test
for length > 0 so it shouldn't be trying to delete
a None object.
Alan G.
More information about the Tutor
mailing list