On Sat, Nov 12, 2011 at 10:56 PM, candide <candide@free.invalid> wrote:
> import foo as f
>
> equivalent to
>
> import foo
> f = foo
>

Not quite, it's closer to:

import foo
f = foo
del foo

without the fiddling around. What the 'import... as' syntax gives is a
way to separate the thing loaded from the name bound to. Suppose
importing were done thus:

foo = import("foo.py")

Then you'd have a standard convention of always importing into a
variable of the same name (loose terminology, but you know what I
mean), with the option of importing as something completely different.
The "import... as" syntax gives the same power, without forcing you to
repeat yourself in the common situation.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to