[Python-Dev] r59947 - in python/trunk:Lib/test/test_structseq.py Misc/NEWS (original) (raw)
Raymond Hettinger python at rcn.com
Mon Jan 14 04:53:57 CET 2008
- Previous message: [Python-Dev] Some tardy mailman checking
- Next message: [Python-Dev] r59947 - in python/trunk:Lib/test/test_structseq.py Misc/NEWS
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
[Christian Heimes]
Log: Added new an better structseq representation. E.g. repr(time.gmtime(0)) now returns 'time.structtime(tmyear=1970, tmmon=1, tmmday=1, tmhour=0, tmmin=0, tmsec=0, tmwday=3, tmyday=1, tmisdst=0)' instead of '(1970, 1, 1, 0, 0, 0, 3, 1, 0)'. The feature is part of #1816: sys.flags
FWIW, I was looking into something similar but didn't proceed because it would break eval(repr(s)) == s as the constructor signature wants all the args in a tuple and won't accept keywords. Still, I think what you did is a nice improvement.
Here's a couple more if you want to proceed down that path:
Have structseq subclass from PyTupleObject so that isinstance(s, tuple) returns True. This makes the object usable whenever tuples are needed.
Add _fields, _asdict, and _replace to match the API in collections.namedtuple(). The _fields tuple should only include the visible positional fields while _asdict() and _replace() should include all of the fields whether visible or accessible only by attribute access.
Thanks for the nice work.
Raymond
- Previous message: [Python-Dev] Some tardy mailman checking
- Next message: [Python-Dev] r59947 - in python/trunk:Lib/test/test_structseq.py Misc/NEWS
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]