String comparison

Tino Wildenhain tino at wildenhain.de
Wed Mar 14 11:44:47 EST 2001


Hi Alexander,

try str(processname)=="netscape"

processname could be a class instance who looks
like a string but is not a string.
Also type(processname) and friends may help to
figure this out.

HTH
Tino Wildenhain

Alexander Stirzel wrote:
> 
> Hi!
> 
> I have a string processname with "netscape" in it and I want to compare
> it with the written word "netscape".
> 
> This are some lines of my source code:
> 
> (...)
> processname = splitted.pop()
> (... no the string netscape is in processname ...)
> if ((processname=="netscape") and ((string.atof(cputimeerg))>45) and
> ((string.atof(cpupercwert))>45)):
> (... the first comparison is false ... why? ...)
> 
> I printed processname just before this comparison and I got "netscape"
> on screen. (With no spaces there, that's not the problem) But when I
> >>>> print (processname=="netscape")
> I get a "0" on screen. And when I
> >>>> print (processname)
> I get "netscape" on screen.
> 
> This is strange...
> 
> Thanks for any help.
> 
> --
> Alexander Stirzel
> E-Mail: alexander.stirzel at daimlerchrysler.com
> *** welcome to hell, here's your copy of windows ***
> --
> http://mail.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list