@decorators

Peter Hansen peter at engcorp.com
Fri Aug 6 14:48:43 EDT 2004


Mark Bottjer wrote:

Mark, would your example still be acceptable to you if someone wrote
it like this?:
> def sillyFunction( a, b, c):
>     """\
>     The silly function does nothing except get "decorated." classmethod
>     determines the form of the first argument (class, object, or
>     other). signature changes the call behavior, asserting the types
>     passed to and returned from the function. Finally, transactional
>     causes boilerplate code to be executed before and after the function
>     body, ensuring that either all changes to database are applied, or
>     none are. Seeing as this function does nothing, this is trivial :).
>     """
>     @classmethod
 >     # PLH 20040806112957: added new decorator here
>     # PLH 20040806130023: also changed last value 
>     @signature( None, a=int, b=float, c=dict)
>     @transactional( database)
>     pass

While I find merit in your idea, it's not entirely fair to discard
the @ syntax because it *can* be written the way you showed, but then
not to perform the same analysis on your own idea.

To be entirely fair, I'm not sure that *any* of the proposed syntaxes
cannot be written in such a way that they get buggered up by intervening
whitespace and comments...  nor should this be a sole reason for
discarding any one.

-Peter



More information about the Python-list mailing list