[Python-Dev] Property syntax (Re: [Python-Dev] Extended Function syntax)

Greg Ewing greg@cosc.canterbury.ac.nz
Fri, 31 Jan 2003 15:10:44 +1300 (NZDT)


Guido:

> Actually I was attempting to find a solution not just for properties
> but for other situations as well.  E.g. someone might want to define
> capabilities, or event handlers, or ...

I'm not sure what a capability is, exactly, so I don't
know what would be required to provide one. Or how an
event handler differs from a method, for that matter.

But anyway, here's another idea:

  def foo as property:
    def __get__(self):
      ...
    def __set__(self, x):
      ...

which would be equivalent to

  foo = property(<dict-from-the-suite>)

or perhaps

  foo = property(<thunk-doing-the-suite>)

You might also want to allow for some arguments somewhere
(not sure exactly where, though).

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	   +--------------------------------------+