Code block function syntax, anonymous functions decorator

castironpi at gmail.com castironpi at gmail.com
Wed Feb 6 15:54:56 EST 2008


def run3( block ):
   for _ in range( 3 ):
      block()

run3():
   normal_suite()

Introduces new syntax; arbitrary functions can follow 'colon'.

Maintains readability, meaning is consistent.

Equivalent to:

def run3( block ):
   for _ in range( 3 ):
      block()

@run3
def anonfunc():
   normal_suite()

Simplification in cases in which decorators are use often.



More information about the Python-list mailing list