[Python-ideas] Deprecate str.find

Carl Johnson cmjohnson.mailinglist at gmail.com
Sat Jul 16 06:50:24 CEST 2011


This is an absolute flight of fancy, and I'm sure it's already been
rejected in the past (a quick search says Aug. 2009,
http://mail.python.org/pipermail/python-ideas/2009-August/thread.html#5576
), but what about some kind of try/except expression?

i = s.index(substr) except ValueError is None

I guess my main problem with that is the color of the bikeshed: it's
hard to get a good idiomatic way of spelling the except expression.
You could use a colon, as proposed in that thread, but it seems to me
a colon indicates a new line follows. I would be for making this as
simple as possible. No "as", no non-implicit "else", and no nesting of
exception types. If you want something fancy, use a statement.



More information about the Python-ideas mailing list