[Python-Dev] Re: Re: Call for defense of @decorators

Bob Ippolito bob at redivi.com
Tue Aug 10 19:34:57 CEST 2004


On Aug 10, 2004, at 1:21 PM, Phillip J. Eby wrote:

> At 12:07 PM 8/10/04 -0400, Chris King wrote:
>
>> Now, is it really that important to a user whether a method is a class
>> or static method?  They're all called the same way (so long as they're
>> bound), and most users couldn't care less how a function is
>> implemented.  If the distinction is really important to the user, then
>> they will presumably be prudent enough to check for this by looking
>> either just below the function name (or wherever decorators end up),
>> or by reading the docstring if the function author decided to document
>> that.
>
> This doesn't apply to other decorators.  For example, some decorators 
> turn a function into a property.  Others change the (effective) call 
> signature.
>
> Indeed, staticmethod changes the call signature, since there is no 
> special first argument.
>
> In frameworks where methods can be wrapped in transactions, lock 
> synchronization, security checks, remote communication, etc., these 
> are all decorations that are potentially part of the interface and 
> important for the reader to know, even if they don't look at the 
> method body (apart from the doc string).

Also, most people that call static methods or class methods probably 
aren't calling them bound to an *instance*.  At least I know that when 
I use classmethods, it's usually to *create* instances.

-bob


More information about the Python-Dev mailing list