On Fri, Mar 20, 2020 at 11:56 AM Dennis Sweeney <sweeney.dennis...@gmail.com>
wrote:

> If ``s`` is one these objects, and ``s`` has ``pre`` as a prefix, then
> ``s.cutprefix(pre)`` returns a copy of ``s`` in which that prefix has
> been removed.  If ``s`` does not have ``pre`` as a prefix, an
> unchanged copy of ``s`` is returned.  In summary, ``s.cutprefix(pre)``
> is roughly equivalent to ``s[len(pre):] if s.startswith(pre) else s``.
>

The second sentence above unambiguously states that cutprefix returns 'an
unchanged *copy*', but the example contradicts that and shows that 'self'
may be returned and not a copy.  I think it should be reworded to
explicitly allow the optimization of returning self.
_______________________________________________
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/SVDEUYYJSI6RRHEOZ54CD55FJRY5N4KM/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to