This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eric.snow
Recipients Guillaume Dominici, eric.snow, rhettinger, serhiy.storchaka
Date 2018-09-21.17:08:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1537549737.42.0.956365154283.issue34761@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2018-09-21 17:08:57eric.snowsetrecipients: + eric.snow, rhettinger, serhiy.storchaka, Guillaume Dominici
2018-09-21 17:08:57eric.snowsetmessageid: <1537549737.42.0.956365154283.issue34761@psf.upfronthosting.co.za>
2018-09-21 17:08:57eric.snowlinkissue34761 messages
2018-09-21 17:08:57eric.snowcreate