[Python-ideas] An iterable version of find/index for strings?
Stephen J. Turnbull
stephen at xemacs.org
Tue Apr 9 02:14:05 CEST 2013
Andrew Barnert writes:
> I don't see how you could think these are equally easy to
> learn. You could show the latter to someone who's never written a
> line of code and they'd already understand it.
I didn't say they are equally easy to learn. My point is simply: How
many of these 3-line functions all alike do we need to have as
builtins? There is a cost to having them all, which may
counterbalance the ease of learning each one.
> There's also the fact that there's literally nothing to get wrong
> with startswith,
Of course there is. It may be the wrong function for the purpose.
.startswith also encourages embedding magic literals in the code.
Both of these make maintenance harder.
> you might as well teach them perl.
Now, now, let's not be invoking Godwin's Law here.
The question "how many do we need" is an empirical question. It
should be obvious I'm not seriously suggesting getting rid of
.startswith; that would have to wait for Python4 in any case.
More information about the Python-ideas
mailing list