Use and usefulness of the as syntax
candide
candide at free.invalid
Thu Nov 17 10:48:32 EST 2011
Le 12/11/2011 13:29, Arnaud Delobelle a écrit :
>> -- The second case seems to be rather widespread and causes math attribute
>> to be private but I don't figure out why this matters.
>
> This way math doesn't get bound in the global namespace when doing
> "from module import *"
>
To contextualize more, I guess you are referring to the following
situation :
# a.py
import math as _math
# b.py
from a import *
print _math.sin(0) # raise a NameError
print math.sin(0) # raise a NameError
so the as syntax is also seful for hiding name, isn'it ?
More information about the Python-list
mailing list