[New-bugs-announce] [issue24047] str.startswith and str.endswith should accept multiple arguments.

Elizabeth Myers report at bugs.python.org
Fri Apr 24 07:49:07 CEST 2015


New submission from Elizabeth Myers:

str.startswith and str.endswith should accept multiple arguments when passing in strings. This makes it easier to check if the first character of a string is one of a given option, versus this awkward construction:

>>> f = 'abc'
>>> 'test'.startswith(tuple(f))
False

With my proposal, this could be shortened to 'test'.startswith(*f) for easy testing.

This also makes it easier to check if a string begins with one of any combination of matches.

----------
components: Interpreter Core, Unicode
messages: 241912
nosy: Elizacat, ezio.melotti, haypo
priority: normal
severity: normal
status: open
title: str.startswith and str.endswith should accept multiple arguments.
type: enhancement
versions: Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24047>
_______________________________________


More information about the New-bugs-announce mailing list