Created
June 14, 2013 16:39
-
-
Save thomasballinger/5783398 to your computer and use it in GitHub Desktop.
Examining __call__ of function objects - it's just a "method-wrapper," an object that wraps what is internally a method. I'm guessing the __call__ method is dynamically created when we ask for it, and there must be a short-circuit where function objects actually can get called with ().
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> def foo(): return 1 | |
>>> foo | |
<function foo at 0x10c5af488> | |
>>> foo.__call__ | |
<method-wrapper '__call__' of function object at 0x10c5af488> | |
>>> foo.__call__.__call__ | |
<method-wrapper '__call__' of method-wrapper object at 0x10c562c50> | |
>>> foo.__call__.__call__.__call__ | |
<method-wrapper '__call__' of method-wrapper object at 0x10c64c8d0> | |
>>> foo.__call__.__call__.__call__() | |
1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment