Fuzzy string comparison
Steven D'Aprano
steve at REMOVE.THIS.cybersource.com.au
Wed Dec 27 09:09:45 EST 2006
On Wed, 27 Dec 2006 02:52:42 -0800, John Machin wrote:
>
> Duncan Booth wrote:
>> "John Machin" <sjmachin at lexicon.net> wrote:
>>
>> > To compare two strings, take copies, and:
>>
>> Taking a copy of a string seems kind of superfluous in Python.
>
> You are right, I really meant don't do:
> original = original.strip().replace(....).replace(....)
> (a strange way of doing things which I see occasionally in other folks'
> code)
Well, sure it is strange if you call the variable "original". But if you
don't care about the original, what's so strange about writing this?
astring = astring.strip().replace(....).replace(....)
Why keep the original value of astring around if you no longer need it?
--
Steven.
More information about the Python-list
mailing list