A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2005-October/057374.html below:

[Python-Dev] Definining properties - a use case for class decorators?

[Python-Dev] Definining properties - a use case for class decorators? [Python-Dev] Definining properties - a use case for class decorators?Nick Coghlan ncoghlan at gmail.com
Mon Oct 17 11:06:47 CEST 2005
Michael Urman wrote:
> class Test(object):
>     class foo(Property):
>         """The foo property"""
>         def get(self): return self._foo
>         def set(self, val): self._foo = val
>         def delete(self): del self._foo
> 
> test = Test()
> test.foo = 'Yay!'
> assert test._foo == 'Yay!'

Thus proving once again, that metaclasses are the one true way to monkey with 
classes ;)

Cheers,
Nick.

P.S. I think I need an email program that disables the send button after 11 
pm. . .

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.blogspot.com
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4