Fred L. Drake, Jr. writes: [describing a suggested property syntax] > class Foo(object): > property myprop: > """A computed property on Foo objects.""" > > def __get__(self): > return ... Perhaps it was obvious to everyone else, but it just occured to me that this lends itself to inheriting descriptor types: class ReadOnly(object): def __get__(self): raise NotImplementedError("sub-class must override this!") def __set__(self): raise AttributeError("read-only attribute") def __delete__(self): raise AttributeError("read-only attribute") class Foo(object): property myprop(ReadOnly): def __get__(self): return ... -Fred -- Fred L. Drake, Jr. <fdrake at acm.org> PythonLabs at Zope Corporation
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