How to determine the bool between the strings and ints?
Jorgen Bodde
jorgen.maillist at gmail.com
Fri Sep 7 11:40:44 EDT 2007
Hi All,
I have a dictionary with settings. The settinfgs can be strings, ints
or bools. I would like to write this list dynamically to disk in a big
for loop, unfortunately the bools need to be written as 0 or 1 to the
config with WriteInt, the integers also with WriteInt and the strings
with a simple Write.
The list is something like;
options[A] = True
options[B] = 1
options[C] = "Hello"
I wanted to use isinstance to determine if it is a bool or an int or a
string. However I am confused trying it out in the interactive editor;
>>> a = False
>>> if isinstance(a, bool):
... print "OK"
...
OK
>>> if isinstance(a, int):
... print "OK"
...
OK
>>>
I don't get it. is the bool derived from 'int' in some way? What is
the best way to check if the config I want to write is an int or a
bool ?
Regards,
- Jorgen
More information about the Python-list
mailing list