Skip to content

Instantly share code, notes, and snippets.

@sneeu
Last active August 29, 2015 14:05
Show Gist options
  • Save sneeu/23e26a938b14417ad057 to your computer and use it in GitHub Desktop.
Save sneeu/23e26a938b14417ad057 to your computer and use it in GitHub Desktop.
>>> class A(object):
... def __init__(self, a):
... self.a = a
... @classmethod
... def f(cls, a):
... return cls(a)
...
>>> class B(A):
... def __init__(self, a, b):
... super(B, self).__init__(a)
... self.b = b
...
>>> A.f(2)
<__main__.A object at 0x100cf5450>
>>> B.f(3)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 6, in f
TypeError: __init__() takes exactly 3 arguments (2 given)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment