TypeError
Dave Angel
d at davea.name
Wed Feb 1 12:15:18 EST 2012
On 02/01/2012 11:53 AM, Clark, Kathleen wrote:
> Hello,
Which python version, what operating system. Doesn't cost much to
specify, and can frequently be relevant.
>
> I am new to python and am trying to correct the follow error:
>
> TypeError: sequence item 1: expected string, NoneType found
>
That's not an error message, it's just the last line of one. Please use
copy/paste to post the entire traceback into your query.
> The error message is referencing line 86 of my code:
>
> ws.cell(row=row, column=1).value = ','.join([str(ino), fn, ln, sdob])
>
And this couldn't be simplified? The sample is not runnable, so we have
to make up a wrapper program to define at least 6 variables, and then
execute this line?
> If I'm understanding this correctly, the code
Which code?
> is expecting a string, but not finding it. I'm wondering, what is meant by a "string" and also how I can figure out the problem and correct it.
>
> If anyone could help me understand what the error is and needs to be done to correct it, I think I might be able to fill in the blanks.
>
> Thanks,
>
> Katie
>
>
If I guess you're running Python 2.7 on Linux 11.04, I could try the
following:
>>> ino = 4
>>> fn = None
>>> ln = 12
>>> sdobj = object()
>>> '.'.join([str(ino), fn, ln, sdobj)
File "<stdin>", line 1
'.'.join([str(ino), fn, ln, sdobj)
^
SyntaxError: invalid syntax
>>> '.'.join([str(ino), fn, ln, sdobj])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: sequence item 1: expected string, NoneType found
>>>
If this matches your circumstance, the problem is that fn has a value of
None. You could have guessed this by simply tucking some print
statements right in front of the offending line, displaying all six
variables, and seeing which is of type NoneType.
So now you have to figure out how fn got that value.
(please don't post graphic attachments to your message, this is a text
mailing list)
--
DaveA
More information about the Python-list
mailing list