[Python-ideas] Deprecate str.find

Raymond Hettinger raymond.hettinger at gmail.com
Sat Jul 16 22:52:29 CEST 2011


I just remembered one other thought on the subject.
Usually, when Python introduces a method such as .index()
that raises an exception for the not-found case, there
are immediate requests for variants that don't raise exceptions:
 dict.pop(key, default)
 dict.get(key, defalut)
 next(iterable, default)
 getattr(obj, attr, default)
 re.match() --> None or matchobject
People seem to hate wrapping try/except around simple calls.
Expect those people to be agitated if you take away str.find().
Raymond


More information about the Python-ideas mailing list

AltStyle によって変換されたページ (->オリジナル) /