Error handling in Python-MySQL

First point: you have too much code in your try/except block. Better to use distinct try/except blocks when you have two statements (or two groups of statements) that may raise different errors: Now do you really have to catch a TypeError here ? If you read at the traceback, you’ll notice that your error comes … Read more

Checking whether a variable is an integer or not

If you need to do this, do unless you are in Python 2.x in which case you want Do not use type. It is almost never the right answer in Python, since it blocks all the flexibility of polymorphism. For instance, if you subclass int, your new class should register as an int, which type will not do: This adheres … Read more