[Python-ideas] Good uses for staticmethod

Guido van Rossum guido at python.org
Sun Jul 24 01:48:42 EDT 2016

What you do in the privacy of your own code is your business, but please
don't pretend it's good style...

On Saturday, July 23, 2016, 王珺 <wjun77 at gmail.com> wrote:

> There is no module or namespace keyword in python. One module consists at
> least one file.
> But sometimes I'm too lazy to create multiple files, or I simply cannot,
> e.g. when writing a plugin for something.
> I write staticmethod as a replacement of module function in these cases.
> 2016-07-23 2:41 GMT+08:00 Random832 <random832 at fastmail.com
> <javascript:_e(%7B%7D,'cvml','random832 at fastmail.com');>>:
>> On Fri, Jul 22, 2016, at 13:51, Guido van Rossum wrote:
>> > Honestly, staticmethod was something of a mistake -- I was trying to
>> > do something like Java class methods but once it was released I found
>> > what was really needed was classmethod. But it was too late to get rid
>> > of staticmethod.
>> Regardless of its utility or lack thereof for methods, staticmethod
>> seems to me to be the best way to make an attribute of a class that
>> happens to be a function (or, theoretically, some other other descriptor
>> object). I like to think of it as an "implicit-magic remover".
>> Probably if it didn't exist something like it would have been proposed
>> eventually, under some other name like @funcattr or something.
>> _______________________________________________
>> Python-ideas mailing list
>> Python-ideas at python.org
>> <javascript:_e(%7B%7D,'cvml','Python-ideas at python.org');>
>> https://mail.python.org/mailman/listinfo/python-ideas
>> Code of Conduct: http://python.org/psf/codeofconduct/

--Guido (mobile)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160723/27bcf5c4/attachment.html>

More information about the Python-ideas mailing list