[Python-Dev] A "record" type (was Re: Py2.6 ideas)
Larry Hastings
larry at hastings.org
Sat Feb 24 05:36:30 CET 2007
Josiah Carlson wrote:
> Larry Hastings <larry at hastings.org> wrote:
>
>> Josiah Carlson wrote:
>>
>>> one thing to note with your method - you can't guarantee the order
>>> of the attributes as they are being displayed.
>>>
>> Actually, my record type *can*; see the hack using the __names__ field.
> Actually, it *can't*. The ordering of the dict produced by the **kwargs
> arguments is exactly same as a regular dictionary.
Just to set the record.py straight, more for posterity than anything else:
Actually, it *does*, because my prototype has explicit support for
imposing such an ordering. That's what the "__names__" field is used
for--it's an optional array of field names, in the order you want them
displayed from __repr__().
Mr. Carlson's posting, while correct on general principles, was just
plain wrong about my code; I suspect he hadn't bothered to read it, and
instead based his reply on speculation about how it "probably" worked.
My "record" prototype has no end of failings, but an inability to
"guarantee the order of the attributes as they are being displayed" is
simply not one of them.
/larry/
More information about the Python-Dev
mailing list