[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 :
    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

Similarly str just returns a copy it does not change
the original. You probably want
            words = str(words)
or just

    File "./parseapps.py", line 50, in mklines
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