from xx import yy (Posting On Python-List Prohibited)

Lawrence D’Oliveiro lawrencedo99 at gmail.com
Tue Nov 14 03:05:10 EST 2017


On Monday, November 13, 2017 at 3:18:04 PM UTC+13, bvdp wrote:
> I'm having a conceptual mind-fart today. I just modified a bunch
> of code to use "from xx import variable" when variable is a global
> in xx.py. But, when I change/read 'variable' it doesn't appear to change.

1) Every name in Python is a variable.
2) Every distinct name (including qualifications) is a distinct variable. Changing one does not automatically change another. “from xx import yy” creates a variable named “yy” in the current scope, initialized to xx.yy but otherwise distinct from it.



More information about the Python-list mailing list