PEP 318 - Function Modifier Syntax

Michele Simionato mis6 at
Tue Jun 10 18:02:15 CEST 2003

Kevin Smith <Kevin.Smith at> wrote in message news:<20030609081617512-0400 at>...
> This is the first draft of a PEP describing new syntax for applying 
> function modifiers (e.g. classmethod, staticmethod, etc).  There is 
> currently no implementation of the proposed syntax (I have heard rumors 
> that the 'def foo(self) [...]' syntax has a patch somewhere, but I 
> haven't seen it yet).  I have already received a few comments and will 
> revise the document soon.  The latest version will always be available 
> at
> Function Modifier Syntax
> ------------------------

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

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: 

def f(x,y) is traced,syncronized: 

which looks better but people protested that "is" has another
meaning. Another possibility (suggested by Bengt Richter) would

class C(A,B) becomes Traced,Syncronized: 

def f(x,y) becomes traced,syncronized: 


More information about the Python-list mailing list