So here's the scene. I have a module as:
Filename A:
import a_local_module
item = [ 1, 2, 3]
Filename B:
import A
list_of_variables = dir(A)
The thing here is that now there is a list of variables from A
and a_local_module
. But I want to get the list of variables declared in file A
and not from its import of a_local_module
.
Also assuming that I don't know what the imports in file A are.
Is there a way to do this?
Just import a_local_module
yourself and compare:
import a_local_module as local
import A
variables = [k
for k, v in vars(A).iteritems()
if getatrr(local, k, object()) is v]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With