Re: [Python-ideas] A decorator to call super()

2017-02-01 Thread Nick Coghlan
On 31 January 2017 at 21:55, Joao S. O. Bueno wrote: > Sure - thanks - I did not even consider the descriptor mechanism, as > I got focused in getting the equivalent from the __class__ cell > inside the decorator code. > > And of course, now there is the

Re: [Python-ideas] A decorator to call super()

2017-01-31 Thread Joao S. O. Bueno
Sure - thanks - I did not even consider the descriptor mechanism, as I got focused in getting the equivalent from the __class__ cell inside the decorator code. And of course, now there is the "__init_subclass__" mechanism - a mixin version using that was as straight forward as it can be as

Re: [Python-ideas] A decorator to call super()

2017-01-31 Thread Ryan Gonzalez
https://github.com/kirbyfan64/mirasu \-- Ryan (ライアン) Yoko Shimomura > ryo (supercell/EGOIST) > Hiroyuki Sawano >> everyone else ___ Python-ideas mailing list Python-ideas@python.org

Re: [Python-ideas] A decorator to call super()

2017-01-31 Thread Ned Batchelder
On 1/31/17 2:13 AM, Roberto Martínez wrote: > Hi, > > I find this type of code quite often: > > class MyOverridedClass(MyBaseClass): > def mymethod(self, foo, **kwargs): > # Do something > return super().mymethod(**kwargs) > > What about creating a decorator to call super()

Re: [Python-ideas] A decorator to call super()

2017-01-31 Thread Yury Selivanov
On 2017-01-31 10:57 AM, Joao S. O. Bueno wrote: BUT - no, it is_not_ an easy decorator to craft - and I don't think it can be made to work cleanly without depending on implementation details of cPython. Pure Python version is certainly possible with descriptor protocol. PoC:

Re: [Python-ideas] A decorator to call super()

2017-01-31 Thread Joao S. O. Bueno
BTW, if one can come up with a pure-Python implementation for these, I'd like to take a peek at the code, please. On 31 January 2017 at 13:57, Joao S. O. Bueno wrote: > On 31 January 2017 at 13:05, Thomas Kluyver wrote: >> On Tue, Jan 31, 2017, at

Re: [Python-ideas] A decorator to call super()

2017-01-31 Thread Joao S. O. Bueno
On 31 January 2017 at 13:05, Thomas Kluyver wrote: > On Tue, Jan 31, 2017, at 02:32 PM, Stephen J. Turnbull wrote: >> Personally, I don't think the explicit invocation is such a big deal >> to need a standardized decorator in the stdlib. > > +1. It's one line either way, and

Re: [Python-ideas] A decorator to call super()

2017-01-31 Thread Thomas Kluyver
On Tue, Jan 31, 2017, at 02:32 PM, Stephen J. Turnbull wrote: > Personally, I don't think the explicit invocation is such a big deal > to need a standardized decorator in the stdlib. +1. It's one line either way, and the explicit call to super() seems clearer for people reading the code.

[Python-ideas] A decorator to call super()

2017-01-31 Thread Stephen J. Turnbull
Roberto Martínez writes: > What about creating a decorator to call super() after/before the > overrided method? I think this is a reasonable idea, but you can do it yourself in a few lines, can't you? Are there any "gotchas" that make it hard to do correctly? Like Sven Kunze, I'm concerned

Re: [Python-ideas] A decorator to call super()

2017-01-31 Thread Roberto Martínez
I think both are useful. I would make this configurable with a flag: class MyOverridedClass(MyBaseClass): @extendsuper(after=True) def mymethod(self, foo): ... Or maybe a pair of decorator is a better option: @pre_super and @post_super El mar., 31 ene. 2017 a las 13:07, Sven R.

Re: [Python-ideas] A decorator to call super()

2017-01-31 Thread Sven R. Kunze
Hi Roberto, On 31.01.2017 08:13, Roberto Martínez wrote: class MyOverridedClass(MyBaseClass): def mymethod(self, foo, **kwargs): # Do something return super().mymethod(**kwargs) What about creating a decorator to call super() after/before the overrided method? Something

[Python-ideas] A decorator to call super()

2017-01-30 Thread Roberto Martínez
Hi, I find this type of code quite often: class MyOverridedClass(MyBaseClass): def mymethod(self, foo, **kwargs): # Do something return super().mymethod(**kwargs) What about creating a decorator to call super() after/before the overrided method? Something like that: class