[Python-ideas] adding an __exec__ method to context managers?

Terry Reedy tjreedy at udel.edu
Tue Oct 13 22:05:53 CEST 2009


Carl Johnson wrote:
> Ben Finney:

> before you find out *how* it's being iterated. For that matter, Python
> has changed the perfectly sensible:
> 
> def method(cls):
>    stuff()
> 
> method = classmethod(method)
> 
> to
> 
> @classmethod
> def method(cls):
>    stuff()
> 
> Why? Because it's more readable to have the decorator up top, so you
> know what kind of function/method to expect.

Part of the motivation for @ you are missing was the desire to not write 
  the function name three times, especially when the name is long, as is 
required in some contexts where functions must be wrapped to interface 
with external systems. The classmethod use case alone would not have 
pushed the addition.

tjr




More information about the Python-ideas mailing list