[Python-Dev] PEP 318: Decorators last before colon

Jewett, Jim J jim.jewett at eds.com
Tue Mar 30 15:38:39 EST 2004


>>     using:
>>         classmethod
>>     def func(arg1, arg2):
>>         pass

> The one major problem that i can see with this kind of 
> syntax is that it is a /special case/ when standard Python
> block structure does not apply.

It warns you that the expressions in the "using:" block will
be evaluated later -- after the "def:" block.

> If we were to stick with standard Python block structure, 
> the 'using' syntax should really be...

> using:
>     classmethod
>     def funct(arg1, arg2):
>        pass

Typically the suite (things indented after the colon) are all
of the same type.

	using classmethod:
	    def funct(arg1, arg2):
	        pass

was unacceptable.

	using classmethod:
	    .version = 2134
	    .author = "anonymous"
	def funct(arg1, arg2):
	    pass

gets the block structure right, but it moves true transformations 
(such as classmethod) too far away.  (Well, unless there is only 
ever one decorator per function, but then this is overkill.)

-jJ




More information about the Python-Dev mailing list