all_vars = dict(vars())
for var_name, var in all_vars.items():
    if type(var) not in [types.ModuleType, types.FunctionType
        ] and not var_name.startswith('_'):
        pass
How to get all variable and method names used in script