[Python-Dev] Extended Function syntax
Oren Tirosh
oren-py-d@hishome.net
Mon, 27 Jan 2003 09:17:37 -0500
On Mon, Jan 27, 2003 at 06:32:22PM +1300, Greg Ewing wrote:
> On Sun, Jan 26, 2003 at 11:46:54PM -0500, Barry A. Warsaw wrote:
> ...
> > Interesting. I've always wanted to be able to write...
> >
> > class Foo:
> > ...
> >
> > def Foo.baz(self, a, b, c):
> > ...
>
> Yes, that would be nice. It would be incompatible with that idea,
> unfortunately.
The statement "def foo(...):" is just a shortcut for the assignment
"foo=new.function(CODE, GLOBS, 'foo')". So why not make "def foo.bar(...):"
a shortcut for "foo.bar=new.function(CODE, GLOBS, 'foo.bar')" ?
If the attributes of a property object are made assignable the following
code will work:
prop = property()
def prop.fget(self):
...
def prop.fset(self, value):
...
This will also allow creating classes the way Barry suggested or creating
new kinds of namespaces.
"Namespaces are one honking great idea -- let's do more of those!"-ly yours,
Oren