En Python, j'essaye d'étendre le type int 'intégré. Ce faisant, je veux passer quelques arguments keywoard au constructeur, donc je le fais:Python: extension int et MRO pour __init__
class C(int):
def __init__(self, val, **kwargs):
super(C, self).__init__(val)
# Do something with kwargs here...
Cependant, tout en appelant C(3)
fonctionne très bien, C(3, a=4)
donne:
'a' is an invalid keyword argument for this function`
et C.__mro__
retourne l'attend:
(<class '__main__.C'>, <type 'int'>, <type 'object'>)
Mais il semble que Python essaie d'appeler int.__init__
d'abord ... Quelqu'un sait pourquoi? Est-ce un bug dans l'interprète?