[Tutor] imported scope
spir
denis.spir at free.fr
Wed Apr 29 15:56:08 CEST 2009
Hello,
I have an issue with scopes (namespaces).
Say I have a source file 'test.py' with the single line:
print vars() # same with locals()
Now, from the command-line:
spir at o:~/prog/pijnu$ python test.py
{'__builtins__': <module '__builtin__' (built-in)>, '__name__': '__main__', '__file__': 'test.py', '__doc__': None}
Right, but when imported (my question is at the bottom of the output ;-):
spir at o:~/prog/pijnu$ python
Python 2.5.2 (r252:60911, Oct 5 2008, 19:24:49)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import test
{'__builtins__': {'IndexError': <type 'exceptions.IndexError'>, 'all': <built-in function all>, 'vars': <built-in function vars>, 'SyntaxError': <type 'exceptions.SyntaxError'>, 'unicode': <type 'unicode'>,
[... here 5918 characters ...]
'AttributeError': <type 'exceptions.AttributeError'>, 'OverflowError': <type 'exceptions.OverflowError'>}, '__name__': 'test', '__file__': 'test.pyc', '__doc__': None}
>>>
Can someone explain?
Denis
------
la vita e estrany
More information about the Tutor
mailing list