How to retrieve all local variables of another module?
<p>I am receiving a module as a parameter and I would like to retrieve all of it's local variables (nothing that relates to <strong>XXX</strong> or a function or a class).<br>
How can that be done?  </p>

<p>I have tried:  </p>

<pre><code>def _get_settings(self, module):
        return [setting for setting in dir(module) if not inspect.ismodule(setting) and not inspect.isbuiltin(setting) and not inspect.isfunction(setting) and not setting.__NAME__.startswith('__')]
</code></pre>

<p>but it raises:  </p>

<pre><code>Traceback (most recent call last):
  File "/home/omer/Aptana Studio 3/plugins/org.python.pydev.debug_1.6.5.2011012519/pysrc/pydevd.py", line 1133, in &lt;module&gt;
    debugger.run(setup['file'], None, None)
  File "/home/omer/Aptana Studio 3/plugins/org.python.pydev.debug_1.6.5.2011012519/pysrc/pydevd.py", line 918, in run
    execfile(file, globals, locals) #execute the script
  File "/root/Aptana Studio 3 Workspace/website/website/manage.py", line 11, in &lt;module&gt;
    import settings
  File "/root/Aptana Studio 3 Workspace/website/website/settings.py", line 7, in &lt;module&gt;
    settings_loader = Loader(localsettings)
  File "/root/Aptana Studio 3 Workspace/website/website/envconf/loader.py", line 6, in __init__
    self.load(environment)
  File "/root/Aptana Studio 3 Workspace/website/website/envconf/loader.py", line 9, in load
    for setting in self._get_settings(module):
  File "/root/Aptana Studio 3 Workspace/website/website/envconf/loader.py", line 16, in _get_settings
    return [setting for setting in dir(module) if not inspect.ismodule(setting) and not inspect.isbuiltin(setting) and not inspect.isfunction(setting) and not setting.__NAME__.startswith('__')]
AttributeError: 'str' object has no attribute '__NAME__'
</code></pre>
