Skip to content

Call built-in method of object instance, lost self param? #132299

@A4-Tacks

Description

@A4-Tacks
>>> class Foo:
...  f=print
...
>>> Foo.f(2)
2
>>> Foo().f(2)
2
>>> def f(*args): print(*args)
...
>>> class Foo:
...  f=f
...
>>> Foo.f(2)
2
>>> Foo().f(2)
<__main__.Foo object at 0x7b16f5e810> 2

Is there any difference between f and print? Is this a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions