data_garden data_garden - 9 days ago 7
Python Question

Python - tracing module execution

I am running a large

script.py
with many
modules
being
imported
, like:

from module import *


when I run it, I am printing some undesired result
[u'Brewer and Shipley']
, at importing time, which I'm not being able to trace back to its
method
and stop it from being executed.

Is there something I can use to trace and stop this?

Answer

While blowing to find out who blew is excellent suggestion by @FMc, Here is another trick I use

import X print 'X imported' import Y print 'Y imported' import Z print 'Z imported'

This will also help you narrow down module with a problem. :)

You can optimize this by doing binary search by printing middle points, but I guess that's over-engg.