[Python-Dev] Definining properties - a use case for class decorators?

Phillip J. Eby pje at telecommunity.com
Wed Oct 19 22:15:33 CEST 2005


At 12:46 PM 10/19/2005 -0700, Josiah Carlson wrote:
>skip at pobox.com wrote:
> > >>>>> "Phillip" == Phillip J Eby <pje at telecommunity.com> writes:
> >
> >     Phillip> Not unless the tuple is passed in as an abstract syntax 
> tree or
> >     Phillip> something.
> >
> > Hmmm...  Maybe I misread something then.  I saw (I think) that
> >
> >     type Foo (base):
> >         def __init__(self):
> >             pass
> >
> > would be equivalent to
> >
> >     class Foo (base):
> >         def __init__(self):
> >             pass
> >
> > and thought that
> >
> >     function myfunc(arg1, arg2):
> >         pass
> >
> > would be equivalent to
> >
> >     def myfunc(arg1, arg2):
> >         pass
> >
> > where "function" a builtin that when called returns a new function.
>
>For it to work in classes, it would need to execute the body of the
>class, which is precisely why it can't work with functions.

Not only that, but the '(arg1, arg2)' for classes is a tuple of *values*, 
but for functions it's just a function signature, not an expression!  Which 
is why this would effectively have to be a macro facility.



More information about the Python-Dev mailing list