Andrew Lentvorski <[EMAIL PROTECTED]> writes:

> How do I determine the order of definition of class attributes?
> 
> For example, if I have a class
> 
> class Test(object):
>     y = 11
>     x = 22
> 
> How do I tell that y was defined before x?

Like any namespace, attributes of an object are implemented as a
dictionary. Dictionaries have no guaranteed order to their items.

If you want to preserve order, do so with a type that preserves such
order:

class Test(object):
    ordered_things = [
        ('y', 11),
        ('x', 22),
        ]

If that doesn't meet your needs, perhaps you could describe what
problem you're trying to solve and we can address it better.

-- 
 \           “We spend the first twelve months of our children's lives |
  `\          teaching them to walk and talk and the next twelve years |
_o__)           telling them to sit down and shut up.” —Phyllis Diller |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to