Python is a pretty regular language; it follows patterns. Most of the time if you can do something in a function, you can do it in global scope or in a class definition or vice versa. There’s an exception for from ... import *
, which works at global scope but not inside a function. The reason why turns out to tell us something interesting about Python internals.
Continue reading “Why doesn’t import * work at function scope?”