Ned Batchelder wrote: > On 12/5/14 4:53 AM, Steven D'Aprano wrote: >> Oh, I learned something new: strictly speaking, this is implementation- >> dependent and not guaranteed to work in the future! >> >> def func(): >> global math >> import math > > I don't think this is implementation-dependent.
The docs say that it is: https://docs.python.org/3/reference/simple_stmts.html#the-global-statement Names listed in a global statement MUST NOT [emphasis added] be defined as formal parameters or in a for loop control target, class definition, function definition, or import statement. CPython implementation detail: The current implementation does not enforce the two restrictions, but programs should not abuse this freedom, as future implementations may enforce them or silently change the meaning of the program. -- Steven -- https://mail.python.org/mailman/listinfo/python-list