Re: generate properties code in class dynamically

2011-05-12 Thread JamesEM
On May 12, 10:04 pm, Terry Reedy wrote: > On 5/12/2011 9:11 AM, JamesEM wrote: > > > > > I would prefer to generate the properties code dynamically from the > > keys of the dictionaries. > > What I am looking for is something like: > > > class MyClass(object): > > >      def __init__(self): > >  

Re: generate properties code in class dynamically

2011-05-12 Thread Terry Reedy
On 5/12/2011 9:11 AM, JamesEM wrote: I would prefer to generate the properties code dynamically from the keys of the dictionaries. What I am looking for is something like: class MyClass(object): def __init__(self): self.d = {} d['field1'] = 1.0 d['field2'] = 'A'

Re: generate properties code in class dynamically

2011-05-12 Thread nn
On May 12, 9:11 am, JamesEM wrote: > Hello, > I have a python class that contains a dictionary. > I would like to use python properties to access the elements of the > dictionary. > This could be achieved as follows: > > class MyClass(object): > >     def __init__(self): >         self.d = {} >  

generate properties code in class dynamically

2011-05-12 Thread JamesEM
Hello, I have a python class that contains a dictionary. I would like to use python properties to access the elements of the dictionary. This could be achieved as follows: class MyClass(object): def __init__(self): self.d = {} d['field1'] = 1.0 d['field2'] = 'A'