Over my head with descriptors

Sarcastic Zombie sarcasticzombie at gmail.com
Mon Dec 18 10:50:45 EST 2006


> > Is there a reason you don't just use __init__ instead of __new__, and use
> > "self.age" and "self.weight" and so on?I was asking myself the same thing...
>
> Chris

"A lack of understanding," he answered sheepishly.

There are attributes (ie, question._qtext) that I do want to be the
same for every instance and thus don't want the extra memory overhead
of storing it anew for each instance.

Using the "instance" reference as you guys suggested, I'm now storing
the instance-specific information that the descriptors validate by
cramming it into instance._foo. Works great now!

Thanks for the additional understanding. It's a lot to wrap one's head
around at first.

-SZ




More information about the Python-list mailing list