[Tutor] Assignment, references, binding (was: is an alias a variable)

Ben Finney ben+python at benfinney.id.au
Mon Feb 17 22:55:59 CET 2014


Ian D <duxbuz at hotmail.com> writes:

> is 
> import longModuleName  as lmn
>  
> or 
>  
> lmn = longModuleName
>  
> creating an alias or assigning to a variable..... or both?

Assignment and import both bind a name to an object. NAmes are one
(common) kind of reference. The only way to get at objects is by using a
reference.

So, this distinction you're drawing doesn't exist in Python. When you
use a name, you're using a reference to an object.

When you assign (or, when ‘import’ assigns) the same object to a
different name, the names are both references to the same object,
without any name having a special status.

-- 
 \         “True greatness is measured by how much freedom you give to |
  `\      others, not by how much you can coerce others to do what you |
_o__)                                               want.” —Larry Wall |
Ben Finney



More information about the Tutor mailing list