Testing and debugging Tips 2.1 Entering a python statement in interactive mode executes one. This mode is especially useful when you are debugging a program.
Test and Debug Tip 2.2 after a file invokes the Python interpreter, the interpreter is launched after the last statement in the file is executed. However, using the-I option (for example, Python-i file.py) to invoke the interpreter on a file causes the compiler to enter interactive mode after executing the statements in the file. This is very useful for debugging the program.
Testing and debugging Tips 2.3 If an expression contains many operators, be sure to refer to the Operator precedence table, and the operators in the appropriate expression execute in the order that they want them to, such as the expression is too complex to determine the order, you may want to split the expression into several small statements, Or simply use parentheses to dictate the order--the same approach can be used in algebraic expressions. Note that some operators (such as the exponentiation operator * *) are associated in a right-to-left order, not from left to right.
Test and debug tip 2.4 to avoid imperceptible errors, be sure to use uniform and correct indentation in your Python program.
Python Testing and debugging Tips