Ordering attributes for dynamically generated class
fairwinds.dp at gmail.com
Mon Jan 19 23:29:14 CET 2009
Hi Aaron, this worked out fine. Using an ordered dict to subclass dict.
On Jan 18, 2009, at 11:57 AM, Aaron Brady wrote:
> On Jan 18, 9:52 am, David Pratt <fairwinds... at gmail.com> wrote:
>> Hi list. I use 'type' to generate classes but have a need to order
>> the attributes for the generated class. Of course a dict is not going
>> to maintain ordering. Is there any way to dynamically generate a
>> class with attributes in specific order?
>> my_new_class = type( 'MyNewClass', tuple_of_bases,
>> Many thanks,
> Just a thought, you can subclass 'dict' and assign an instance of it
> to the __dict__ member of your new instance.
More information about the Python-list