On Sun, Mar 22, 2020 at 4:20 AM Eric V. Smith <e...@trueblade.com> wrote:

> Agreed. I think the PEP should say that a str will be returned (in the
> event of a subclass, assuming that's what we decide), but if the
> argument is exactly a str, that it may or may not return the original
> object.
>

Yes. Returning self if the class is exactly str is *just* an optimization
-- it must not be mandated nor ruled out.

And we *have* to decide that it returns a plain str instance if called on a
subclass instance (unless overridden, of course) since the base class (str)
won't know the signature of the subclass constructor. That's also why all
other str methods return an instance of plain str when called on a subclass
instance.

-- 
--Guido van Rossum (python.org/~guido)
*Pronouns: he/him **(why is my pronoun here?)*
<http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/ZZTY3OCJFZTZM74MVWRYL23LFJGNKICU/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to