2017-02-06 23:55:37 -05:00
|
|
|
"""
|
|
|
|
categories: Types,int
|
|
|
|
description: No int conversion for int-derived types available
|
|
|
|
cause: Unknown
|
2017-07-09 07:33:55 -04:00
|
|
|
workaround: Avoid subclassing builtin types unless really needed. Prefer https://en.wikipedia.org/wiki/Composition_over_inheritance .
|
2017-02-06 23:55:37 -05:00
|
|
|
"""
|
2021-03-15 09:57:36 -04:00
|
|
|
|
|
|
|
|
2017-02-06 23:55:37 -05:00
|
|
|
class A(int):
|
|
|
|
__add__ = lambda self, other: A(int(self) + other)
|
|
|
|
|
2021-03-15 09:57:36 -04:00
|
|
|
|
2017-02-06 23:55:37 -05:00
|
|
|
a = A(42)
|
2021-03-15 09:57:36 -04:00
|
|
|
print(a + a)
|