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

c# SetCompatibleTextRenderingDefault must be called before the first -

c++ - Fill runtime data at compile time with templates -

C#.NET Oracle.ManagedDataAccess ConfigSchema.xsd -