classification
Title: str.endswith and str.startswith do not take lists of strings
Type: enhancement Stage:
Components: Interpreter Core Versions: Python 3.3
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: eric.smith, mark.dickinson, py.user
Priority: normal Keywords:

Created on 2012-01-10 04:09 by py.user, last changed 2012-01-10 12:42 by rhettinger. This issue is now closed.

Messages (3)
msg151002 - (view) Author: py.user (py.user) * Date: 2012-01-10 04:09
>>> 'abcd'.endswith(['a', 'b'])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Can't convert 'list' object to str implicitly
>>>

it would be nice like in str.join
>>> ''.join(('a', 'b'))
'ab'
>>> ''.join(['a', 'b'])
'ab'
>>> ''.join({'a', 'b'})
'ab'
>>> ''.join({'a': 1, 'b': 2})
'ab'
>>>
msg151011 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2012-01-10 11:21
No, but they take tuples:

>>> 'abcd'.endswith(('a', 'b'))
False
>>> 'abcd'.endswith(('c', 'd'))
True

Suggest closing as out of date.
msg151013 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2012-01-10 12:34
It seems like a set would make more sense than a tuple. And if tuples, why not lists?

Not that it matters much, since I doubt it's worth changing in either case. It's easy enough for the caller to convert.
History
Date User Action Args
2012-01-10 12:42:06rhettingersetstatus: open -> closed
resolution: rejected
2012-01-10 12:34:46eric.smithsetnosy: + eric.smith
messages: + msg151013
2012-01-10 11:21:42mark.dickinsonsetversions: + Python 3.3, - Python 3.1
nosy: + mark.dickinson

messages: + msg151011

type: behavior -> enhancement
2012-01-10 04:09:28py.usercreate