Use and usefulness of the as syntax

candide candide at free.invalid
Sat Nov 12 06:56:17 EST 2011


First, could you confirm the following syntax

import foo as f

equivalent to

import foo
f = foo



Now, I was wondering about the usefulness in everyday programming of the 
as syntax within an import statement. Here are some instances retrieved 
from real code of such a syntax

import numpy as np

import math as _math

import pickle as pickle


-- In the first case, the syntax is motivated by brevity need, isn't it ?
-- The second case seems to be rather widespread and causes math 
attribute to be private but I don't figure out why this matters.
-- In the last case, I can see no point

So what is the pragmatics of the as syntax ?

Thanks for clarification.



More information about the Python-list mailing list