Message107108
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. |
|
Date |
User |
Action |
Args |
2010-06-04 22:51:31 | terry.reedy | set | recipients:
+ terry.reedy, jackdied, r.david.murray, benrg |
2010-06-04 22:51:31 | terry.reedy | set | messageid: <1275691891.34.0.159102110547.issue8847@psf.upfronthosting.co.za> |
2010-06-04 22:51:29 | terry.reedy | link | issue8847 messages |
2010-06-04 22:51:29 | terry.reedy | create | |
|