[Python-ideas] The prohibition overrides the class method

Ryan Gonzalez rymg19 at gmail.com
Mon Nov 16 13:24:51 EST 2015


You could always put this in the docstring:

DO NOT OVERRIDE THIS METHOD. IF YOU OVERRIDE THIS METHOD, YOU WILL DIE.


Short, the-the-point, and evokes fear.

...

Seriously, though, I personally think this might go well with the whole PEP 484 type-annotation thing. I mean, if there are already generics and abstract methods. If we're going for static typing, adding final would fit well. Something like:

@finalmethod
def whatever(self): ...

The type checker (in this case, Mypy) would check it, but there would be no runtime effect.

On November 16, 2015 12:15:55 PM CST, "Иван Спиненко" <spinenkoia at gmail.com> wrote:
>Thank you for the constructive responses, perhaps, I agree with you
>that
>this is not in the spirit of Python.
>As for the real example of the use, sometimes there to make the
>implementation of the method in the base class, but that none of the
>rest
>of the development team could not accidentally or unknowingly override
>this
>method (perhaps due to the need to be unsuccessful architecture).
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Python-ideas mailing list
>Python-ideas at python.org
>https://mail.python.org/mailman/listinfo/python-ideas
>Code of Conduct: http://python.org/psf/codeofconduct/

-- 
Sent from my Nexus 5 with K-9 Mail. Please excuse my brevity.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20151116/9cad8f4b/attachment.html>


More information about the Python-ideas mailing list