Terry J. Reedy <[email protected]> added the comment:
More experiments
from collections import namedtuple
foo = namedtuple('foo', '')
a = [] + foo()
print (a, type(a), len(a))
# () <class 'tuple'> 0
ie, a standard empty tuple, whereas
a = [1,1] + foo()
crashes immediately. So the behavior of list()+namedtuple depends on the length
of the list.
There are also some funny interactions. Adding
try:
a = foo()+[]
except TypeError:
print("correct TypeError")
after the 'foo = ' line in my original 5 line example causes the final print to
crash, whereas adding the same 4 lines to the 4 line example at the beginning
of this message does not obviously change anything.
David, since you omitted all details, I wonder if you tested in batch mode, as
I did, and hence never tried to print the malformed object, or used different
OS or hardware.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue8847>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com