This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2012年01月10日 04:09 by py.user, last changed 2022年04月11日 14:57 by admin. 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 |
| 2022年04月11日 14:57:25 | admin | set | github: 57964 |
| 2012年01月10日 12:42:06 | rhettinger | set | status: open -> closed resolution: rejected |
| 2012年01月10日 12:34:46 | eric.smith | set | nosy:
+ eric.smith messages: + msg151013 |
| 2012年01月10日 11:21:42 | mark.dickinson | set | versions:
+ Python 3.3, - Python 3.1 nosy: + mark.dickinson messages: + msg151011 type: behavior -> enhancement |
| 2012年01月10日 04:09:28 | py.user | create | |