[Tutor] is an alias a variable

emile emile at fenx.com
Fri Jan 31 21:41:02 CET 2014


On 01/31/2014 01:57 AM, Ian D wrote:
> Hi
>
> is
> import longModuleName  as lmn
>
> or
>
> lmn = longModuleName
>
> creating an alias or assigning to a variable..... or both?

Yes (I'm not goint to get into the symantic issues of what's an alias or 
variable)

Python 2.7.3 (default, Nov  2 2012, 09:35:42)
[GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-85)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> import sys as s
 >>> m = s
 >>> id(m)
1075446500
 >>> id(s)
1075446500
 >>>

The id's are the same so they refer to the same object.

Emile





More information about the Tutor mailing list