Hi All,
I see. It works.
Thanks,
GZ
On Nov 18, 12:04 pm, Ian Kelly wrote:
> On Fri, Nov 18, 2011 at 7:51 AM, GZ wrote:
> > Hi,
>
> > I have a class Record and a list key_attrs that specifies the names of
> > all attributes that correspond to a primary key.
>
> > I can write a function like thi
On Fri, Nov 18, 2011 at 7:51 AM, GZ wrote:
> Hi,
>
> I have a class Record and a list key_attrs that specifies the names of
> all attributes that correspond to a primary key.
>
> I can write a function like this to get the primary key:
>
> def get_key(instance_of_record):
> return tuple(instance
GZ wrote:
> For example, if key_attrs=['A','B'], I want the generated function to
> be equivalent to the following:
>
> def get_key(instance_of_record):
>return (instance_of_record['A'],instance_of_record['B'] )
>
> I realize I can use eval or exec to do this. But is there any other
> way t
GZ wrote:
Hi,
I have a class Record and a list key_attrs that specifies the names of
all attributes that correspond to a primary key.
I can write a function like this to get the primary key:
def get_key(instance_of_record):
return tuple(instance_of_record.__dict__[k] for k in key_attrs)
Ho