Hi All,
I see. It works.
Thanks,
GZ
On Nov 18, 12:04 pm, Ian Kelly ian.g.ke...@gmail.com wrote:
On Fri, Nov 18, 2011 at 7:51 AM, GZ zyzhu2...@gmail.com 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
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)
However,
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)
GZ zyzhu2...@gmail.com 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
On Fri, Nov 18, 2011 at 7:51 AM, GZ zyzhu2...@gmail.com 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