[issue42334] Subclassing int and complex with keyword arguments weird
Dennis Sweeney
report at bugs.python.org
Fri Nov 13 00:36:10 EST 2020
Dennis Sweeney <sweeney.dennis650 at gmail.com> added the comment:
This is because int, str, and complex are immutable. If I have
class MyInt(int):
def __init__(self, stuff):
pass
then when I call MyInt("19"), the string "19" is passed to the constructor int.__new__ before the overridden initializer MyInt.__init__. You can only override that by implementing a MyInt.__new__ to override the int constructor.
This is not a bug.
----------
nosy: +Dennis Sweeney
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42334>
_______________________________________
More information about the Python-bugs-list
mailing list