[Python-checkins] [Python-Dev] r59947 - in python/trunk:Lib/test/test_structseq.py Misc/NEWS

Guido van Rossum guido at python.org
Mon Jan 14 05:15:57 CET 2008


On Jan 13, 2008 7:53 PM, Raymond Hettinger <python at rcn.com> wrote:
> [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.

Hmm, is that really necessary? structseq has been in use for quite a
while and this need hasn't come up -- it's been designed to be quite
compatible with tuple *except* for isinstance checks, and that has
worked well.

> 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 at python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/guido%40python.org
>



-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-checkins mailing list