New submission from Alan Beccati <[email protected]>:
Hello,
did I discover a python string comparison bug or is this behaviour expected and
I am doing something wrong?
This is the code I run:
for line in lines[4:]:
currColl=line.split(":")[1].strip()
print "'",currColl,"'","==","'",collName,"'"
if currColl == collName :
return True
else:
print "not equal"
where currColl is a method parameter and lines is built from subprocess Popen
like:
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
lines=[]
for line in p.stdout.readlines():
lines.append(line)
The output of the abovementioned code is:
' utm ' == ' utm10 '
not equal
' utm1000 ' == ' utm10 '
not equal
' utm100 ' == ' utm10 '
not equal
' utm10 ' == ' utm10 '
not equal
' utm1 ' == ' utm10 '
not equal
as you can see the fourth comparison should return True while it gives a "not
equal" as the others.
Python info:
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24)
[GCC 4.5.2] on linux2
----------
messages: 147854
nosy: Alan.Beccati
priority: normal
severity: normal
status: open
title: string comparison with ==
type: behavior
versions: Python 2.7
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue13427>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com