[Python-ideas] Decorator to avoid a mistake
François Leblanc
fleblanc50 at gmail.com
Sat Nov 26 01:12:44 EST 2016
Le 26 nov. 2016 4:27 AM, "Guido van Rossum" <guido at python.org> a écrit :
>
> This idea is being kicked around from forum to forum and nobody wants to
have it.
Sorry, I want to have it but I dont want to pay the price in performance
cost..
> Here it's brought up from time to time and the response is usually "let a
linter do it".
It's true, but in other hand because the subject come back from time to
time, perhaps something better can be imagine the need is here.
> In mypy (which is essentially a powerful linter) it was proposed (
https://github.com/python/mypy/issues/1888) and the response was
essentially "better go to python-ideas or bugs.python.org".
>
> It's also been proposed as a PEP 484 feature:
https://github.com/python/typing/issues/269#issuecomment-243765549 .
>
> I think one reason why such proposals are unwelcome to experienced users
may be that when done right this is totally legitimate, and the requirement
to use an @override decorator is just making code more verbose with very
little benefit. (I could see a benefit -- if this is used consistently it
could make spelunking a large codebase easier, because you would know which
methods are overrides. Something like mypy could then enforce its use. But
an IDE could also just highlight method overrides differently, maybe
PyCharm or PyDev already do that?)
The goal is not to make the code more verbose at all, it's to make code
more sure in big or/and collaborative projects.
The goal it's to give the possibility to secure the use of one of the more
powerful feature of python.
I think this kind of mistake may slow the time development and consequently
afraid manager of using python in business environnement.
Last time i have extend a Tkinter Top le vel and get in trouble with some
comportement, I've just introduce a configuration function in my extended
class. We often give same name for same functionnalities and that is the
trouble if its not volontary.
In case the function or variable is runtime defined its very hard to detect
the error and pylint tools like will not help...
> --
> --Guido van Rossum (python.org/~guido)
>
> _______________________________________________
> 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/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20161126/8087c1bb/attachment-0001.html>
More information about the Python-ideas
mailing list