aboutsummaryrefslogtreecommitdiff
path: root/tests/cpydiff/types_int_subclassconv.py
blob: 5d337412c7f530c617a584739c07dba79b2a9e62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
"""
categories: Types,int
description: No int conversion for int-derived types available
cause: Unknown
workaround: Avoid subclassing builtin types unless really needed. Prefer https://en.wikipedia.org/wiki/Composition_over_inheritance .
"""


class A(int):
    __add__ = lambda self, other: A(int(self) + other)


a = A(42)
print(a + a)