Duncan Booth <duncan@rcp.co.uk>: > Something like this might work (although it is getting a bit messy): > > def set(fn): > get, delete, doc = None, None, fn.__doc__ > namespace = inspect.getcurrentframe().f_back.f_locals > oldfn = namespace.get(fn.__name__) > > if isinstance(oldfn, property): > get, delete, doc = oldfn.fget, oldfn.fdel, oldfn.__doc__ > return property(get, fn, delete, doc) I think there's something that needs to be decided before going any further with this: Do we want to be able to define and/or override get/set/del methods individually? If so, it would be better to re-design the property mechanism to make it easier, instead of coming up with kludges to fit it on top of the existing mechanism. Whatever the mechanism, here's my current thoughts on a property syntax: def foo.get(self): ... def foo.set(self, x): ... def foo.del(self): ... Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg@cosc.canterbury.ac.nz +--------------------------------------+
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