Dynamic scoping in python