[Python-ideas] str.startswith taking any iterator instead of just tuple

Bruce Leban bruce at leapyear.org
Mon Jan 6 08:06:10 CET 2014


On Sun, Jan 5, 2014 at 9:48 AM, Andrew Barnert <abarnert at yahoo.com> wrote:

> > Reading this thread made me start to think about why a string is a
> sequence, and I can't actually see any obvious reason, other than
> historical ones.
>
> You've seriously never indexed or sliced a string? Those are the two core
> operations in sequences, and they're obviously useful on strings.
>

I am doing most coding in two languages right now: Python and Javascript. I
have never wished that Python had string.charAt(i) but I have often wished
that Javascript had string[i]. When I've iterated over the characters in a
string in Javascript, it has never occurred to me to write it using
str.split('').

By irrelevant analogy, I have never used complex numbers in Python or
Javascript and I can't see any obvious reason to support them. It just
confuses people who inadvertently write cmath.sqrt instead of math.sqrt.
For the few people that use complex numbers, they would be better served by
a tuple of real and imaginary parts. As someone who doesn't use them, my
opinion is clearly more important that that of those that use them.

--- Bruce
Learn how hackers think: http://j.mp/gruyere-security

(Not serious about removing complex numbers from Python. If you didn't see
the sarcasm, sorry.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140105/20b7b087/attachment.html>


More information about the Python-ideas mailing list