locals->globals for py 3.x

A subtle change is made in py 3.x such that the locals() dictionary
inside a list comprehension is onloy local to the list comprehension