[Answer]-Global variables don't works in Django shell

1πŸ‘

βœ…

I tried the equivalent of your code in python 2.6 and django 1.3 and it works fine. Not suggesting you downrev, but at least this might be a clue. Also, if you are just using s, then you don’t need the global declaration inside your function. I think you only need that if you are modifying s.

In [60]: import subprocess as s

In [61]: def test():
    global s
    f = s.check_call('ls /tmp', shell=True)
    return f
   ....:

In [65]: test()
Out[65]: 0
πŸ‘€marlacparker

Leave a comment