String comparison

Fredrik Lundh fredrik at pythonware.com
Wed Mar 14 10:55:12 EST 2001


Alexander Stirzel wrote:
> 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.

maybe you have control characters (e.g. a carriage
return) left in the string?

try

>>> print repr(processname)

or just

>>> processname

(nit: print is a statement, not a function call.  don't use
parentheses around its argument)

Cheers /F

<!-- (the eff-bot guide to) the standard python library:
http://www.pythonware.com/people/fredrik/librarybook.htm
-->





More information about the Python-list mailing list