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. Kunze (<srku...@mail.de>)
escribió:

> 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 like that:
>
> class MyOverridedClass(MyBaseClass):
>     @extendsuper
>     def mymethod(self, foo):
>         # Do something
>
>
> I could find this useful. There's just on bikeshedding issue:
>
> When should "super().mymethod(**kwargs)" be called: *before*, *after* or
> inbetween my specialized code?
>
> Depending on the baseclass either of those three is necessary. As far as I
> can tell, we encounter all of them regularly.
>
> Best,
> Sven
>
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to