Order in metaclass

Nicolas Fleury nid_oizo at yahoo.com_remove_the_
Wed Oct 13 16:42:28 CEST 2004

Carlos Ribeiro wrote:
> Of course, we are now getting into corner cases that show how much are
> we pushing class  statements in Python. The _sane_ way to make it all
> work would be to have a hook to provide a user-defined dict to the
> class locals() dir; aternatively, the natice dict() could provide a
> ordered interface (but then it wouldn't be a simple hash mapping, a
> more complex structure such as a tree would be needed). Both are far
> from happening in Python 2.x, IMHO... and I really doubt if dicts will
> ever be changed to accomodate ordering, even in Python 3.0. Too much
> hassle for too little gain. A hook function seems to be more sensible.

I don't know.  I was thinking that maybe an ordereddict class would be 
useful, something like:

myDict = {'a': 4, 'b': 5 }  # normal dict
myDict = o{'a': 4, 'b': 5 }  # ordered dict, keeping order ['a', 'b']

The dictionary could only be use in specific cases, like configuration 
stuff or temporarily when instantiating a metaclass...  I don't know, 
maybe I'm just crazy...


More information about the Python-list mailing list