[Tutor] Using new style classes and __slots__
ml.cyresse at gmail.com
Sat Sep 24 23:37:08 CEST 2005
> You might want to learn more about the whole property mechanism then. property() is actually a bit of sugar over a deeper mechanism. Also there is an interesting idiom for creating properties using @apply (in Python 2.4) - look for Benji York's comment in this recipe:
Thanks Kent. Just looking at that above recipe, I'm not too sure how
the @ decorators work.
>From what I understand, it defines would turn apply() into a function
that returns the various get/sets?
Also found something interesting with property(), if it's called in
__init__ you get
<property object at 0x011598C8>
whereas called outside __init__ it works normally.
This is a hassle for me because I'm a lazy typist, so I've been using
setattr() to pull attribute names out of a list. And the first
argument setattr() requires is an object, and self doesn't work
outside of a method, and using the class name leads to no attribute
Hmm, may have to learn even more about classes and their internals.
More information about the Tutor