Any way to catch potentially undefined variables in Python? -


although enjoy working python, i'm big fan languages enforce variable declaration before use, because catches silly spelling mistakes in variables before code run.

is there utility can scan python files , warn if thinks variable potentially undeclared?

there no pure python utility know of can perform function want. however, dynamic variable declaration can used part of program flow the try...except structure:

if some_input:     = 5  try:     print except nameerror:     do_something 

Comments

Popular posts from this blog

sql - can we replace full join with union of left and right join? why not? -

javascript - Parallax scrolling and fixed footer code causing width issues -

iOS: Performance of reloading UIImage(name:...) -