On 3/26/2020 9:10 PM, Ethan Furman wrote:
First off, thank you for being so patient -- trying to champion a PEP can be exhausting.

On 03/26/2020 05:22 PM, Dennis Sweeney wrote:
So now if I understand the dilemma up to this point we have:

Benefits of writing ``return self`` in the PEP:
    a - Makes it clear that the optimization of not copying is allowed
    b - Makes it clear that ``self.__class__.__getitem__`` isn't used

Benefits of writing ``return self[:]`` in the PEP:
    c - Makes it clear that returning self is an implementation detail
    d - For subclasses not overriding ``__getitem__`` (the majority of cases), makes        it clear that this method will return a base str like the other str methods.

Did I miss anything?

The only thing you missed is that, for me at least, points A, C, and D are not at all clear from the example code.  If I wanted to be explicit about the return type being
`str` I would write:

     return str(self)   # subclasses are coerced to str

That does seem like the better solution, including the comment.

Eric
_______________________________________________
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/43GEOBNJYN22QLYMG2PGN3KDOSQQHR6E/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to