[Python-Dev] Dafanging the find() gotcha
05 Aug 2002 17:29:35 -0400
Guido> Andrew appears to say that if you object against '' in 'abc' not
Guido> raising an exception, you should also object against the other one;
Guido> but his real point is the corollary: since you don't object against
Guido> giving 'ab' in 'abc' new meaning, you shouldn't object against a new
Guido> meaning for '' in 'abc' either -- at least not based on the argument
Guido> of breaking code. Whenever we say that a change doesn't break code,
Guido> we almost always imply "except code that depends on a particular thing
Guido> raising an exception".
Guido> Tim is arguing that '' in 'abc' is not a useful question to ask. The
Guido> usefulness of the exception is not that it's a feature on which
Guido> correct programs depend, but that it's an early warning that your
Guido> program is broken. Losing that early warning sign would mean more
Guido> time wasted debugging.
Guido> OTOH I'm worried that some code doing some mathematical proof using
Guido> substring relationships would find it irritating to have to work
Guido> around the irregularity. But I admit that this is a purely
Guido> theoretical fear for now.
On the other hand, I have a practical fear: There are lots of
different ways of asking whether a string s contains a substring s1.
If those ways behave in diverse manners when s1 is empty, I am going
to have to remember which way to obtain which behavior. I would
really like to avoid having to do that.
Andrew Koenig, firstname.lastname@example.org, http://www.research.att.com/info/ark