Update for clarity: I'm looking for a function that will return information about the namespace of a script (i.e. list all the variable names, function names, class names etc. that are explicitly defined in the script).
Consider the following scenario,
#script 1.py
a = 'spam'
def makeOmlette():
print('eggs and spam')
return None
#script 2.py
a = 'bacon'
def makeOmlette():
print('eggs and bacon')
#Desired Capability:
>>> import someBuiltInModule
>>> someBuiltInModule.BuiltInNameSpaceChecker.compare( scrips = ['folder//script1.py', 'folder//script2.py'])#which would return...
('Scripts are not compatable',
'global variable "a defined in files script1.py and script2.py',
'function "makeOmlette" defined in files cript1.py and script2.py',
'other useful information before you might combine the two...')
The goal would be to check if copying and pasting script 1 and 2 into the same file would cause any namespace overlap.
Yes, I know, I could just have the new script use import statements.
#script 3 - onlyWayIKnow.py
import script_1
import script_2
>>> script_1.a == script_2.a
False
The reason for my inquiry (in case I am thinking about this wrong) is that if I use the aforementioned solution, I would then have to maintain 3 scripts going forward instead of just 1.