C
Chris Curvey
Hi all,
I have this program
class Company:
def __init__(self, revenues, costs):
self.revenues = revenues
self.costs = costs
def __getattr__(self, name):
if name == 'profits':
return self.revenues - self.costs
c = Company(100, 75)
print c.revenues
print c.costs
print c.profits
import cPickle
print cPickle.dumps(c)
Everything works fine up until the last line. If I remove the
__getattr__ function, then everything works (except "print c.profits").
What is the cPickle class trying to get to that is causing my
__getattr__ function to be called?
-Chris
I have this program
class Company:
def __init__(self, revenues, costs):
self.revenues = revenues
self.costs = costs
def __getattr__(self, name):
if name == 'profits':
return self.revenues - self.costs
c = Company(100, 75)
print c.revenues
print c.costs
print c.profits
import cPickle
print cPickle.dumps(c)
Everything works fine up until the last line. If I remove the
__getattr__ function, then everything works (except "print c.profits").
What is the cPickle class trying to get to that is causing my
__getattr__ function to be called?
-Chris