On 14 January 2018 at 08:20, Chris Angelico <rosuav at gmail.com> wrote: > On Sun, Jan 14, 2018 at 7:10 PM, joannah nanjekye > <nanjekyejoannah at gmail.com> wrote: > > Hello, > > > > Apparently when you implement two methods with the same name: > > > > def sub(x, y): > > print(x -y) > > > > def sub(x, y): > > print(x -y) > > > > Even with type hints. > > > > def sub(x: int, y:int) -> int: > > return x - y > > > > def sub(x: float, y:float) -> float: > > return 8 > > > > If you are from another background, you will expect the syntax with type > > hints to act as though method overloading but instead last > implementation is > > always called. If this is the required behavior,then just flag any > duplicate > > method implementations as syntax errors. > > > > Is this sort of method name duplication important in any cases? > > > > Not aimed at criticism, just to understand. > > This is not an error in the language for the same reason that any > other assignment isn't an error: > > x = 5 > x = 6 > > But you will find that a number of linters will flag this as a > warning. You can configure your editor to constantly run a linter and > show you when something's wrong. > For example mypy (and probably also PyCharm) warn about variable/function/class re-definition. -- Ivan -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20180114/f2f51833/attachment.html>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4