Today, When i do some testing in "python manage.py shell", the global var can't referenced, see:
In [9]: import subprocess as s
In [10]: def test():
global s
f = s.check_output('ls /tmp', shell=True)
return f
....:
In [11]: test()
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
/usr/local/lib/python2.7/dist-packages/django/core/management/commands/shell.pyc in <module>()
----> 1 test()
/usr/local/lib/python2.7/dist-packages/django/core/management/commands/shell.pyc in test()
1 def test():
2 global s
----> 3 f = s.check_output('ls /tmp', shell=True)
4 return f
**NameError: global name 's' is not defined**
Every global var i try to reference are face the same error. But put the code in views.py, it works.... How could i fix the django shell?