searching backwards in a string
Paul Rubin
phr-n2002a at nightsong.com
Thu Feb 14 01:15:50 EST 2002
Skip Montanaro <skip at pobox.com> writes:
> Paul> here 50000 and -1 are the starting and ending locations.
>
> Skip> If start > end isn't direction == -1 implied?
>
> Paul> Nope. I tried it and it didn't search backwards.
>
> That wasn't quite what I was asking. Let me ask it a slightly
> different way. Presuming the behavior can be changed so that
> searching in reverse works, shouldn't the ordering of start and end
> be sufficient to indicate the direction of the search?
That might have been an ok way for the implementers to have originally
designed the re module, but they designed and documented a different
way instead. Changing the behavior now of already-documented
arguments could break existing programs. It's better to add a new arg
to preserve compatibility, and it's a cleaner design anyway to use a
separate arg.
More information about the Python-list
mailing list