Skip to content

Instantly share code, notes, and snippets.

@mozillazg
Created May 7, 2014 06:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mozillazg/b75849f5a450a05deb19 to your computer and use it in GitHub Desktop.
Save mozillazg/b75849f5a450a05deb19 to your computer and use it in GitHub Desktop.
In [1]: class A():
...: def __call__(self, *args, **kwargs):
...: return locals()
...:
In [2]: a = A()
In [3]: a()
Out[3]: {'args': (), 'kwargs': {}, 'self': <__main__.A instance at 0x281b2d8>}
In [4]: a(1)
Out[4]: {'args': (1,), 'kwargs': {}, 'self': <__main__.A instance at 0x281b2d8>}
In [5]: a(1,3)
Out[5]: {'args': (1, 3), 'kwargs': {}, 'self': <__main__.A instance at 0x281b2d8>}
In [6]: a(1, 3, c=4)
Out[6]:
{'args': (1, 3),
'kwargs': {'c': 4},
'self': <__main__.A instance at 0x281b2d8>}
In [7]:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment