Re: [Python-ideas] staticmethod and classmethod should be callable

2018-06-22 Thread Random832
On Thu, Jun 21, 2018, at 05:00, INADA Naoki wrote: > When Python 4, I think we can even throw away classmethod and staticmethod > object. > PyFunction can have binding flag instead, like METH_CLASS and METH_STATIC > for PyCFunction. > classmethod and staticmethod is just a function which modify

Re: [Python-ideas] staticmethod and classmethod should be callable

2018-06-22 Thread Nick Coghlan
On 21 June 2018 at 03:27, Serhiy Storchaka wrote: > 20.06.18 20:07, Guido van Rossum пише: >> >> Maybe we're misunderstanding each other? I would think that calling the >> classmethod object directly would just call the underlying function, so this >> should have to call utility() with a single

Re: [Python-ideas] staticmethod and classmethod should be callable

2018-06-21 Thread Brendan Barnwell
On 2018-06-21 01:33, Serhiy Storchaka wrote: 21.06.18 10:45, Jeroen Demeyer пише: >On 2018-06-20 19:33, Serhiy Storchaka wrote: >>20.06.18 12:56, Jeroen Demeyer пише: >>>Are there any reasons to*not* make staticmethod and classmethod >>>callable? >> >>There were no reasons to make

Re: [Python-ideas] staticmethod and classmethod should be callable

2018-06-21 Thread Jeroen Demeyer
On 2018-06-21 11:00, INADA Naoki wrote: When Python 4, I think we can even throw away classmethod and staticmethod object. PyFunction can have binding flag instead, like METH_CLASS and METH_STATIC for PyCFunction. classmethod and staticmethod is just a function which modify the flag. One issue

Re: [Python-ideas] staticmethod and classmethod should be callable

2018-06-21 Thread INADA Naoki
> > > My question is really: assuming that we redesign > staticmethod/classmethod anyway, should we make them callable? > ​I think so. staticmethod and classmethod should affect descriptor behavior. And it should behave as normal function.​ >>> @classmethod ... def foo(cls): ... print(cls)

Re: [Python-ideas] staticmethod and classmethod should be callable

2018-06-21 Thread Jeroen Demeyer
On 2018-06-21 10:33, Serhiy Storchaka wrote: Status quo wins. Well, I'm already planning to make changes to staticmethod/classmethod (not right now, but it's on my post-PEP-580 roadmap). So the "status quo" argument doesn't apply. My question is really: assuming that we redesign

Re: [Python-ideas] staticmethod and classmethod should be callable

2018-06-21 Thread Serhiy Storchaka
21.06.18 10:45, Jeroen Demeyer пише: On 2018-06-20 19:33, Serhiy Storchaka wrote: 20.06.18 12:56, Jeroen Demeyer пише: Are there any reasons to *not* make staticmethod and classmethod callable? There were no reasons to make staticmethod and classmethod callable. You have to compare the

Re: [Python-ideas] staticmethod and classmethod should be callable

2018-06-21 Thread Jeroen Demeyer
On 2018-06-20 19:33, Serhiy Storchaka wrote: 20.06.18 12:56, Jeroen Demeyer пише: Are there any reasons to *not* make staticmethod and classmethod callable? There were no reasons to make staticmethod and classmethod callable. You have to compare the advantages of making them callable vs.

Re: [Python-ideas] staticmethod and classmethod should be callable

2018-06-20 Thread Guido van Rossum
Maybe. Though it has surprised me occasionally that pulling a classmethod or staticmethod out of the class dict (like in Jeroen's original example) doesn't work. On Wed, Jun 20, 2018 at 10:34 AM Serhiy Storchaka wrote: > 20.06.18 12:56, Jeroen Demeyer пише: > > Are there any reasons to *not*

Re: [Python-ideas] staticmethod and classmethod should be callable

2018-06-20 Thread Serhiy Storchaka
20.06.18 12:56, Jeroen Demeyer пише: Are there any reasons to *not* make staticmethod and classmethod callable? There were no reasons to make staticmethod and classmethod callable. Just "for consistency" is not considered a good reason. ___

Re: [Python-ideas] staticmethod and classmethod should be callable

2018-06-20 Thread Serhiy Storchaka
20.06.18 20:07, Guido van Rossum пише: Maybe we're misunderstanding each other? I would think that calling the classmethod object directly would just call the underlying function, so this should have to call utility() with a single arg. This is really the only option, since the descriptor

Re: [Python-ideas] staticmethod and classmethod should be callable

2018-06-20 Thread Guido van Rossum
On Wed, Jun 20, 2018 at 10:03 AM Serhiy Storchaka wrote: > 20.06.18 19:37, Guido van Rossum пише: > > On Wed, Jun 20, 2018 at 9:31 AM Serhiy Storchaka > > > > wrote: > > > > 20.06.18 19:20, Guido van Rossum пише: > > > +1 -- when we introduced these we

Re: [Python-ideas] staticmethod and classmethod should be callable

2018-06-20 Thread Serhiy Storchaka
20.06.18 19:37, Guido van Rossum пише: On Wed, Jun 20, 2018 at 9:31 AM Serhiy Storchaka > wrote: 20.06.18 19:20, Guido van Rossum пише: > +1 -- when we introduced these we didn't see the use case so clearly, > but it definitely exists. How

Re: [Python-ideas] staticmethod and classmethod should be callable

2018-06-20 Thread Guido van Rossum
On Wed, Jun 20, 2018 at 9:31 AM Serhiy Storchaka wrote: > 20.06.18 19:20, Guido van Rossum пише: > > +1 -- when we introduced these we didn't see the use case so clearly, > > but it definitely exists. > > How would you call a classmethod descriptor in this case? > With an extra first argument

Re: [Python-ideas] staticmethod and classmethod should be callable

2018-06-20 Thread Serhiy Storchaka
20.06.18 19:20, Guido van Rossum пише: +1 -- when we introduced these we didn't see the use case so clearly, but it definitely exists. How would you call a classmethod descriptor in this case? ___ Python-ideas mailing list Python-ideas@python.org

Re: [Python-ideas] staticmethod and classmethod should be callable

2018-06-20 Thread Guido van Rossum
+1 -- when we introduced these we didn't see the use case so clearly, but it definitely exists. On Wed, Jun 20, 2018 at 4:44 AM Steven D'Aprano wrote: > On Wed, Jun 20, 2018 at 11:56:05AM +0200, Jeroen Demeyer wrote: > [...] > > Since it makes sense to merge the classes "classmethod" and > >

Re: [Python-ideas] staticmethod and classmethod should be callable

2018-06-20 Thread Steven D'Aprano
On Wed, Jun 20, 2018 at 11:56:05AM +0200, Jeroen Demeyer wrote: [...] > Since it makes sense to merge the classes "classmethod" and > "classmethod_descriptor" (PEP 579, issue 8), one of the above behaviors > should be changed. Given that adding features is less likely to break > stuff, I would

[Python-ideas] staticmethod and classmethod should be callable

2018-06-20 Thread Jeroen Demeyer
While working on PEP 579 and friends, I noticed one oddity with classmethods: for Python classes, the object stored in the class __dict__ is of type "classmethod". For extension types, the type is "classmethod_descriptor". In turns out that the latter is callable itself, unlike staticmethod or