You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Call built-in method of object instance, lost self param? #132299
>>> f =lambda*args: print(*args)
>>> f.__self__
Traceback (most recent call last):
File "<python-input-1>", line 1, in <module>
f.__self__
AttributeError: 'function' object has no attribute '__self__'. Did you mean: '__call__'?
>>> print.__self__
<module 'builtins' (built-in)>
If you take look on the print declaration, it has self argument (bound to it's module):
Activity
skirpichev commentedon Apr 9, 2025
There is:
If you take look on the print declaration, it has
selfargument (bound to it's module):cpython/Python/bltinmodule.c
Lines 2159 to 2162 in 16dcb57
IIUIC, rules for module functions are like for classmethods, described here: https://docs.python.org/3/reference/datamodel.html#instance-methods
Maybe it should be explained better in https://docs.python.org/3.14/reference/datamodel.html#built-in-functions. BTW,
__self__description here is wrong - at least here we have a documentation issue.