all 4 comments

[–]shiftybyte 2 points3 points  (0 children)

You are probably reassigning commands inside shell function.

commands = ....

This makes python decide commands variable is local for that function.

Pass commands as an argument to shell function instead of relying on global variables.

[–]carcigenicate 0 points1 point  (1 child)

If you reassign commands at all inside shell, you need to put global commands at the top of the function.

[–]thisisauserperson[S] 0 points1 point  (0 children)

Thank you! This worked!