Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Even without going to the trouble of importing types, every Python callable has an __call__ method. Including the __call__ method:

    >>> def f():
    ...  print("Helllo __call__")
    ... 
    >>> f.__call__.__call__.__call__.__call__()
    Helllo __call__
Don't use this in real life though, there's a performance penalty.


Of course, there's also the singleton that always returns itself:

  >>> recursive = lambda: recursive




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: