Eric Snow <ericsnowcurren...@gmail.com> added the comment:

As Serhiy said, this is the correct behavior.  Nearly all builtin operations 
are made using the appropriate "dunder" method from the object's type (not 
looked up on the object itself).  So the following (based on your example) are 
equivalent:

  s = super(Child, self)
  print(type(s).__str__(s))
  print(str(s))

In contrast, explicitly calling __str__() on the instance involves lookup 
there, so the following are equivalent:

  s = super(Child, self)
  print(s.__str__())
  print(type(s).__getattribute__(s, '__str__')())

You can read more about "dunder" (AKA "special") methods and how they are 
looked up in the docs. [1][2][3]

I'm going to close this issue, but if you think there's anything further we can 
do in the documentation to avoid confusion then please let us know.


[1] https://docs.python.org/3/reference/datamodel.html#special-lookup
[2] https://docs.python.org/3/reference/datamodel.html#special-method-names
[3] 
https://docs.python.org/3/library/inspect.html#fetching-attributes-statically

----------
nosy: +eric.snow
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34761>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to