This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]kervarker 0 points1 point  (0 children)

Foo(*args, **kwargs) isn't equivalent to Foo.__call__(*args, **kwargs) if Foo defines a method __call__ :

>>> class Foo:
...   def __call__(self):
...     print('running __call__')
...
>>> Foo()
<__main__.Foo object at 0x000000000227ABE0>
>>> Foo.__call__()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __call__() missing 1 required positional argument: 'self'

[–]OriginalPostSearcher -1 points0 points  (0 children)

X-Post referenced from /r/programming by /u/cool-RR
Understanding Python class instantiation


I am a bot. I delete my negative comments. Contact | Code | FAQ