[Python-Dev] Re: Dafanging the find() gotcha
Tue, 06 Aug 2002 10:46:52 -0400
Tim> I don't count that as "a practical fear" unless you actually
Tim> search for empty strings, and I don't believe that you do (or at
Tim> least not on purpose -- you can change my mind in a hurry by
Tim> posting your Python code that does do so, though!).
Andrew> A hypothetical example for you.
Andrew> Imagine an interactive program that [...] present[s] a form to
Andrew> fill out [which] looks like this:
Andrew> Search only files containing this string:
Andrew> If the user doesn't type anything into this part of the form, we
Andrew> would like the search to cover all files.
I think this is an extremely unconvincing example. You have pushed the
API up to the user of a program and supposed that they expect the
behavior which you are trying to defend. In practice, what users expect
in cases where a field is left blank is for that field to be IGNORED,
not for it to be processed, but its contents treated as containing an
If you had an algorithm which worked on strings generally but only if
the null string behavior was as desired, that would be convincing. But
saying that the user might expect this behavior seems a poor argument...
user's expectations are usually Do-What-I-Mean, not Do-It-Right.
Programming languages, though, work better when designed to Do-It-Right.
Perl-being-the-exception-that-proves-the-rule -lly yours,
-- Michael Chermside