I am populating a dictionary from an input file, and would like to create an error code if a string is sent to a variable that expects a float or int.
INPUT = {} for line in open(infile): input_line = line.split(' = ') INPUT[input_line[0].strip()] = input_line[1].strip() if INPUT.has_key('ReferencePositionX'): refx = float(INPUT['ReferencePositionX'])/10 refy = float(INPUT['ReferencePositionY'])/10 refz = float(INPUT['ReferencePositionZ'])/10 I have many variables of different types, and I want to do a check in case something like ReferencePositionX = abc occurs. -- "The game of science can accurately be described as a never-ending insult to human intelligence." - João Magueijo
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor