how to cause a request for a missing class attribute cause its calculation

Vincent Davis vincent at vincentdavis.net
Tue May 18 16:39:13 EDT 2010


Lets say I have
class foo(object):
    def __init__(self, x, y):
        self.x=x
        self.y=y
    def xplusy(self):
        self.xy = x+y

inst = foo(1,2)
inst.xy   # no value, but I what this to cause the calculation of inst.xy

I don't what to have self.xy calculated before it is called.


Thanks

*Vincent Davis
720-301-3003 *
vincent at vincentdavis.net
 my blog <http://vincentdavis.net> |
LinkedIn<http://www.linkedin.com/in/vincentdavis>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100518/3d8bf7ec/attachment.html>


More information about the Python-list mailing list