[Tutor] Interesting problem
jsmith at medplus.com
Thu Jun 23 20:43:43 CEST 2005
I can see I wasn't clear :-)
Here's the basic framework of what I'm looking for. Needless to say,
this is just an example and not the real problem which is quite
complicated and includes multiple classes.
What I'm looking for is the actual implementation of get_props_as_dict
which I've written here as pseudo-code
self._var1 = val1
self._var2 = val2
var1 = property(lambda s: s._var1)
var2 = property(lambda s: s._var2)
return self._var1 + self._var2
var3 = property(_var3)
d = dict()
for prop in properties:
d[prop_name] = prop_value
From: tutor-bounces at python.org [mailto:tutor-bounces at python.org] On
Behalf Of Smith, Jeff
Sent: Thursday, June 23, 2005 2:01 PM
To: tutor at python.org
Subject: [Tutor] Interesting problem
Consider a class with a lt of properties. I would like a member
function which generates a dictionary where the keys are the property
names and the values are the property values?
Is this clear?
How might I go about this?
Tutor maillist - Tutor at python.org
More information about the Tutor