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

class MyClass:
        def __init__(self):
                self._var1 = val1
                self._var2 = val2

        var1 = property(lambda s: s._var1)
        var2 = property(lambda s: s._var2)

        def _var3(self):
                return self._var1 + self._var2

        var3 = property(_var3)

        def getprops_as_dict(self):
                d = dict()
                for prop in properties:
                        d[prop_name] = prop_value
                return d

Thanks,
Jeff

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Smith, Jeff
Sent: Thursday, June 23, 2005 2:01 PM
To: tutor@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?

Jeff
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to