All pastes #424625 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-04-04 22:28 UTC
rendered paste body
class MyInt2(int):
    __slots__ = ['oid']
    oid = 20
    def __init__(self, orig, oid=None):
        int.__init__(self, orig)
        self.oid = oid

int2 = MyInt2(2000, oid=10)

print int2
print int2.oid


Lanza el error:
[eroldan@dedo k3]$ python test.py
Traceback (most recent call last):
  File "test.py", line 8, in ?
    int2 = MyInt2(2000, oid=10)
TypeError: 'oid' is an invalid keyword argument for this function