September 2013
Intermediate to advanced
350 pages
9h 38m
English
An alias is an alternative name for something. In Python, two variables are said to be aliases when they contain the same memory address. For example, the following code creates two variables, both of which refer to a single list:

When we modify the list using one of the variables, references through the other variable show the change as well:
| | >>> celegans_phenotypes = ['Emb', 'Him', 'Unc', 'Lon', 'Dpy', 'Sma'] |
| | >>> celegans_alias = celegans_phenotypes |
| | >>> celegans_phenotypes[5] = 'Lvl' |
| | >>> celegans_phenotypes |
| | ['Emb', 'Him', 'Unc', ... |
Read now
Unlock full access