So, it seems that in many situations we have to code if isinstance (n, (int, Integer)) instead of if isinstance (n, Integer), despite the fact that the latter is much more natural. Sigh.