X is not a type object (int)

Viewed 19

If i try to create a subclass of int and define __new__ on that class, I get a weird type error that I've never seen before and I wasn't able to see it mentioned anywhere:

class o(int):
    def __new__(cls, *args, **kwargs):
        return super().__new__(*args, **kwargs)

p = o(2)
TypeError: int.__new__(X): X is not a type object (int)
0 Answers
Related