Michael Spencer wrote:
> a.split() == b.split() is a convenient test, provided you want to normalize
> whitespace rather than ignore it. I took the OP's requirements to mean that
> 'A B' == 'AB', but this is just a guess.
I'm sure someone has studied this in more detail, but intuitively, parti
Hi Michael,
Normalizing the whitespace is what I was looking to do. I guess that
that aspect of my original query was not enough clear. But with either
solutions, I get the result I wanted.
Greetings,
Olivier Langlois
http://www.quazal.com
> -Original Message-
> Fredrik Lundh wrote:
>
Fredrik Lundh wrote:
>
" hello world ".split()
> ['hello', 'world']
a.split() == b.split() is a convenient test, provided you want to normalize
whitespace rather than ignore it. I took the OP's requirements to mean that
'A B' == 'AB', but this is just a guess.
Michael
--
http://mail.
[EMAIL PROTECTED] wrote:
>> > I would like to make a string comparison that would return true without
>> > regards of the number of spaces and new lines chars between the words
>> >
>> > like 'A B\nC' = 'A\nBC'
>
> Here is how I do such comparisons:
>
> if a.strip().split() == b.strip().spl
[EMAIL PROTECTED] wrote:
> Michael Spencer wrote:
>> Olivier Langlois wrote:
>>
>> > I would like to make a string comparison that would return true without
>> > regards of the number of spaces and new lines chars between the words
>> >
>> > like 'A B\nC' = 'A\nBC'
>
> Here is how I do such
Michael Spencer wrote:
> Olivier Langlois wrote:
>
> > I would like to make a string comparison that would return true without
> > regards of the number of spaces and new lines chars between the words
> >
> > like 'A B\nC' = 'A\nBC'
Here is how I do such comparisons:
if a.strip().split()
Alex Martelli wrote:
> Michael Spencer <[EMAIL PROTECTED]> wrote:
>>
>> Here, str.translate deletes the characters in its optional second argument.
>> Note that this does not work with unicode strings.
>
> With unicode, you could do something strictly equivalent, as follows:
>
> nowhite = dict.f
Michael Spencer <[EMAIL PROTECTED]> wrote:
> Olivier Langlois wrote:
>
> > I would like to make a string comparison that would return true without
> > regards of the number of spaces and new lines chars between the words
>
> >
> > like 'A B\nC' = 'A\nBC'
> >
>
> import string
> NULL = s
Michael Spencer <[EMAIL PROTECTED]> wrote:
> Olivier Langlois wrote:
> > Hi Michael!
> >
> > Your suggestion is fantastic and is doing exactly what I was looking
> > for! Thank you very much.
> > There is something that I'm wondering though. Why is the solution you
> > proposed wouldn't work with
Olivier Langlois wrote:
> Hi Michael!
>
> Your suggestion is fantastic and is doing exactly what I was looking
> for! Thank you very much.
> There is something that I'm wondering though. Why is the solution you
> proposed wouldn't work with Unicode strings?
>
Simply, that str.translate with two a
Hi Michael!
Your suggestion is fantastic and is doing exactly what I was looking
for! Thank you very much.
There is something that I'm wondering though. Why is the solution you
proposed wouldn't work with Unicode strings?
Olivier Langlois
http://www.quazal.com
>
> import string
> NULL = string.m
Olivier Langlois wrote:
> I would like to make a string comparison that would return true without
> regards of the number of spaces and new lines chars between the words
>
> like 'A B\nC' = 'A\nBC'
>
import string
NULL = string.maketrans("","")
WHITE = string.whitespace
def compare(a,b)
Hi,
I would like to make a string comparison that would
return true without regards of the number of spaces and new lines chars between
the words
like ‘A B\nC’ = ‘A\nB
C’
What would be the easiest way to do it in Python?
Thanks,
Olivier Langlois
http://www.quazal.com
13 matches
Mail list logo