Hi,

> 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:
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/410698

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
>>> a.a
<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
being set.

Hmm, may have to learn even more about classes and their internals.

Regards,

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

Reply via email to