[Python-Dev] Extended Function syntax
Greg Ewing
greg@cosc.canterbury.ac.nz
Mon, 27 Jan 2003 12:52:05 +1300 (NZDT)
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 +--------------------------------------+