Code block function syntax, anonymous functions decorator
Diez B. Roggisch
deets at nospam.web.de
Wed Feb 6 17:59:27 EST 2008
castironpi at gmail.com schrieb:
> 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.
This is non-sensical - how do you invoke anonfunc? They would all bind
to the same name, run3. Or to no name as all, as your "spec" lacks that.
Besides, it's butt-ugly IMHO. But taste comes after proper definition...
Diez
More information about the Python-list
mailing list