At Thursday 7/12/2006 01:58, George Sakkis wrote:

Simon Bunker wrote:

> Basically I want to have the Input class as a gateway that does lots of
> checking when the attibute is assigned or read.
>
> I have had a look at __getattribute__(), but this gets very ugly as I
> have to check if the attribute is an Input class or not.
>
> Also I don't think property() is appropriate is it? All of the
> attributes will essentially be doing the same thing - they should not
> have individual set/get commands.
>
> Is there any way of doing this nicely in Python?

What about __setattr__ ? At least from your example, checking happens
only when you set an attribute. If not, post a more representative
sample of what you're trying to do.

Or search the Python Cookbook - there are zillions of variants on how to manage properties (using inner classes, using decorators, using closures, using ...). Traits (code.enthought.com) may be useful too.


--
Gabriel Genellina
Softlab SRL
__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! ¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to