Accessors in Python (getters and setters)

Diez B. Roggisch deets at nospam.web.de
Thu Jul 20 11:50:15 EDT 2006


> You mean:
> 
> class Pythonic(object):
>     def __init__(self):
>       self._is_active = True
> 
>     @apply
>     def is_active():
>       def fget(self): return self._is_active
>       def fset(self): raise SomeException('sorry, read-only')
>       return property(**locals())

Neat! That slipped my attention over all this noisy and pointless 
discussion...

Regards,

Diez



More information about the Python-list mailing list