"Bryan Fodness" <[EMAIL PROTECTED]> wrote
I have many variables of different types, and I want to do a check
in
case something like ReferencePositionX = abc occurs.
In Python its usual to tackle that using try/except.
If you get a TypeError then try type conversion.
The saying goes somethinn
On 31/07/2008, Bryan Fodness <[EMAIL PROTECTED]> wrote:
> 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(' = ')
> IN
Bryan,
How about checking your input to see if they are digits or not?
>>> input_data = '123ABC'
>>> print input_data.isdigit()
False
>>> input_data = '1234567889'
>>> print input_data.isdigit()
True
>>> input_data = '123ABC'
>>> print input_data.isdigit()
False
or something like:
while INPUT.h
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(