PEP 318 - Function Modifier Syntax
Robin Becker
robin at jessikat.fsnet.co.uk
Tue Jun 10 12:37:22 EDT 2003
In article <2259b0e2.0306100802.c805a50 at posting.google.com>, Michele
Simionato <mis6 at pitt.edu> writes
....
in this scheme you're notationally overriding the __metaclass__ for the
class, is there a default __metadef__ concept to go along with the
methods?
is
class A:
__metadef__ = traced
......
could make all of A's methods 'traced'.
>
>I proposed some type ago to extend the notation for classes. For instance
>
>class C(A,B)[Traced,Syncronized]: pass
>
>would mean
>
>class C(A,B): __metaclass__=type("TracedSyncronized",(Traced,Syncronized),{})
>
>For functions instead the interpretation would be
>
>def f(x,y)[traced,syncronized]: pass
>
>meaning (as in the current PEP)
>
>def f(x,y): pass
>f=traced(syncronized(f))
>
>It is not perfect, since the interpretation of the syntax would differ
>for functions and classes, but who cares? "practicality beats purity" ;)
>
>Originally I wanted an "is" sugar
>
>class C(A,B) is Traced,Syncronized:
> pass
>
>def f(x,y) is traced,syncronized:
> pass
>
>which looks better but people protested that "is" has another
>meaning. Another possibility (suggested by Bengt Richter) would
>be
>
>class C(A,B) becomes Traced,Syncronized:
> pass
>
>def f(x,y) becomes traced,syncronized:
> pass
>
>
> Michele
--
Robin Becker
More information about the Python-list
mailing list