[Tutor] string from input file

Bryan Fodness bryan.fodness at gmail.com
Tue Apr 29 23:54:29 CEST 2008


I am trying to get values from an input file,

     0.192
     Custom
     15
     IN

but, when I check to see if they are equal it is not true.

     f = open(infile, 'r')
     s = f.readlines()
     f.close()

     Block = str(s[1])
     Angle = float(s[2])
     Position = str(s[3])
     if Block == 'Custom':
           print 'equal'

if I print Block+'Custom', I get,

     Custom
     Custom

when I would have expected

     CustomCustom

Can someone help me figure out if  I am not reading the values in correctly,
is there a control character at the end?  The float value is ok.

-- 
"The game of science can accurately be described as a never-ending insult to
human intelligence." - João Magueijo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20080429/24f58997/attachment.htm>


More information about the Tutor mailing list