Haven’t written python code for more than one year, I met this simple problem:

import zkpython
....
res = zookeeper.get_children(handle, path, zk_watcher)
a = len(res)
b = res[0]
print a, b
if a >= b:
    print "OK"

Even the code have print out the value of “a” and “b” as 2 and 1, the condition check “if a >= b:” is false!
Spending more than 10 minutes, I eventually get the reason: the type of “a” is “int” but “b” is “string” (and the interpreter of Python will not report any warning about this “inconsistency”). I should have been taking enough care of the type of these variables.
Seems “print” can’t reveal adequate details of a variable, therefore it is highly suggested we using “pprint” instead of “print”.

import pprint
...
pprint.pprint(a)
pprint.pprint(b)

The result will be

2
'1'