[issue44521] str.removeprefix(): add strict: bool

2021-06-28 Thread Dennis Sweeney
Dennis Sweeney added the comment: I'm +-0 on this. I would write something like this instead: assert whatever.startswith(prefix) result = whatever.removeprefix(prefix) Note that if this were to change, the corresponding methods would also have to change on bytes, bytearray, and colle

[issue44521] str.removeprefix(): add strict: bool

2021-06-28 Thread Terry J. Reedy
Terry J. Reedy added the comment: Start by presenting this idea on python-ideas list. -- nosy: +terry.reedy ___ Python tracker ___

[issue44521] str.removeprefix(): add strict: bool

2021-06-28 Thread Jack DeVries
Change by Jack DeVries : -- nosy: +lemburg ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pytho

[issue44521] str.removeprefix(): add strict: bool

2021-06-28 Thread Jack DeVries
Jack DeVries added the comment: @lemburg, hopefully I'm asking the right person... you're down as the devguide expert on unicode and these changes would (I think) need to be applied here:: Objects/unicodeobject.c::12814 unicode_removeprefix_impl Anyway, do you think this would be a useful fe

[issue44521] str.removeprefix(): add strict: bool

2021-06-28 Thread Марк Коренберг
Марк Коренберг added the comment: Any kwarg is OK for me, so please do. -- ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue44521] str.removeprefix(): add strict: bool

2021-06-28 Thread Jack DeVries
Jack DeVries added the comment: @Jelle Zijlstra, they did think about this in the pep; see here https://www.python.org/dev/peps/pep-0616/#id26 The PEP authors suggested a kwarg of ``required`` which is certainly better. Maybe ``raise_exception`` would be even more explicit albeit verbose. I

[issue44521] str.removeprefix(): add strict: bool

2021-06-28 Thread Jelle Zijlstra
Jelle Zijlstra added the comment: ValueError would seem to be the right exception to use. If this parameter were to be added (I'm not convinced that it should be), I'd prefer to call it something more specific than "strict", since "strict" can mean lots of things. -- nosy: +Jelle Zi

[issue44521] str.removeprefix(): add strict: bool

2021-06-28 Thread Марк Коренберг
New submission from Марк Коренберг : #39939 introduced .removeprefix for several classes. I propose adding kwargs-only parameter `, *, strict: bool = False`. It should raise some exception (I'm unuse what exactly) if the string DOES NOT start from specified prefix. False by default only for co