Re: Ordering attributes for dynamically generated class

2009-01-19 Thread David Pratt
Hi Aaron, this worked out fine. Using an ordered dict to subclass dict. Many thanks. David On Jan 18, 2009, at 11:57 AM, Aaron Brady wrote: On Jan 18, 9:52 am, David Pratt wrote: Hi list. I use 'type' to generate classes but have a need to order the attributes for the generated class. Of cou

Re: Ordering attributes for dynamically generated class

2009-01-18 Thread Duncan Booth
Aaron Brady wrote: > On Jan 18, 9:52 am, David Pratt 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 attri

Re: Ordering attributes for dynamically generated class

2009-01-18 Thread David Pratt
Hi Aaron. Yeah, definitely sounds like a possibility. I was able to locate an ordered dict implementation that subclasses dict. This might work fine. Might be able to pass into type method directly since I think that dict passed into type is setting __dict__ I believe. Let you know if tha

Re: Ordering attributes for dynamically generated class

2009-01-18 Thread Aaron Brady
On Jan 18, 9:52 am, David Pratt 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? >

Ordering attributes for dynamically generated class

2009-01-18 Thread David Pratt
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_base