Is there a way to automatically verify all imports in a Python script without running it? -


suppose have long python script (too long hand-audit) contains expensive operation, followed bunch of library function calls dependent on output of expensive operation.

if have not imported necessary modules library function calls, python error out after expensive operation has finished, because python interprets line line.

is there way automatically verify have necessary imports without either a) manually verifying line line or b) running through expensive operation each time miss library?

another way put question whether there tool c compiler respect verifying dependencies before run time.

no, not possible, because dependencies can injected @ runtime.

consider:

def foo(break_things):     if not break_things:         globals()['bar'] = lambda: none  long_result = ... foo(long_result > 0) bar() 

which depending on runtime value of long_result, may give nameerror: name 'bar' not defined.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -