[Python-Dev] Why wont duplicate methods be flagged as error (syntax or anything suitable error) (original) (raw)
joannah nanjekye nanjekyejoannah at gmail.com
Sun Jan 14 03:10:33 EST 2018
- Previous message (by thread): [Python-Dev] Deprecate PEP 370 Per user site-packages directory?
- Next message (by thread): [Python-Dev] Why wont duplicate methods be flagged as error (syntax or anything suitable error)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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.
-- Joannah Nanjekye +256776468213 F : Nanjekye Captain Joannah S : joannah.nanjekye T : @Captain_Joannah SO : joannah
"You think you know when you learn, are more sure when you can write, even more when you can teach, but certain when you can program." Alan J. Perlis -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20180114/54fdc669/attachment.html>
- Previous message (by thread): [Python-Dev] Deprecate PEP 370 Per user site-packages directory?
- Next message (by thread): [Python-Dev] Why wont duplicate methods be flagged as error (syntax or anything suitable error)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]