[Christian Heimes]
> Log:
> Added new an better structseq representation. E.g. repr(time.gmtime(0)) now 
> returns 'time.struct_time(tm_year=1970, tm_mon=1, 
> tm_mday=1, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=3, tm_yday=1, tm_isdst=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:

1. Have structseq subclass from PyTupleObject so that isinstance(s, tuple) 
returns True.  This makes the object usable whenever 
tuples are needed.

2. 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
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to