Member variable in object spontaneously turns to None
Alex Martelli
aleax at aleax.it
Sun Nov 10 03:22:29 EST 2002
Norbert wrote:
...
> print "%d" % matrix[1][1].x
> None
>
> I am perplexed. Any help would be appreciated. Thanks.
So am I: I think the latter behavior is impossible -- if that x attribute
was None, no matter how it became so, you'd get a TypeError
from the formatting operator (since you're using %d, not %s) --
a result string of 'None' from '%d'%... is impossible for any RHS
operand of %. I'm completely unable to reproduce the problem
you report.
Can you please try to reproduce the problem in a small complete
script? Otherwise I'll have to assume that what you posted was
not a copy-and-paste of observed behavior, but a summary that
happened to omit crucial information.
Alex
More information about the Python-list
mailing list