Larry Hastings <[EMAIL PROTECTED]> 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.  
> It won't preserve that order during iteration--but it's only a prototype 
> so far, and it could be fixed if there was interest.

Actually, it *can't*.  The ordering of the dict produced by the **kwargs
arguments is exactly same as a regular dictionary.

    >>> def foo(**k):
    ...     return k
    ...
    >>> foo(b=1, a=2)
    {'a': 2, 'b': 1}
    >>> foo(hello=1, world=2)
    {'world': 2, 'hello': 1}

After construction you can preserve the order it has, but you've already
lost the order provided in the call, so the order you get is arbitrarily
defined by implementation details of dictionaries and hash(str).


 - Josiah

_______________________________________________
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