Python 
Aliasing 
Copyright © Software Carpentry 2010 
This work is licensed under the Creative Commons Attribution License 
See http://software-carpentry.org/license.html for more information.
An alias is a second name for a piece of data 
Python Aliasing
An alias is a second name for a piece of data 
Often easier (and more useful) than making a 
sseeccoonndd ccooppyy 
Python Aliasing
An alias is a second name for a piece of data 
Often easier (and more useful) than making a 
sseeccoonndd ccooppyy 
If the data is immutable, aliases don't matter 
Python Aliasing
An alias is a second name for a piece of data 
Often easier (and more useful) than making a 
sseeccoonndd ccooppyy 
If the data is immutable, aliases don't matter 
Because the data can't change 
Python Aliasing
An alias is a second name for a piece of data 
Often easier (and more useful) than making a 
sseeccoonndd ccooppyy 
If the data is immutable, aliases don't matter 
Because the data can't change 
But if data can change, aliases can result in a lot 
of hard-to-find bugs 
Python Aliasing
Aliasing happens whenever one variable's value 
is assigned to another variable 
Python Aliasing
Aliasing happens whenever one variable's value 
is assigned to another variable 
first = 'isaac' 
vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee 
first 'isaac' 
Python Aliasing
Aliasing happens whenever one variable's value 
is assigned to another variable 
first = 'isaac' 
second = first 
vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee 
first 
second 
'isaac' 
Python Aliasing
Aliasing happens whenever one variable's value 
is assigned to another variable 
first = 'isaac' 
second = first 
But as we've already seen… 
vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee 
first 
second 
'isaac' 
Python Aliasing
Aliasing happens whenever one variable's value 
is assigned to another variable 
first = 'isaac' 
second = first 
But as we've already seen… 
vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee 
first = first + ' newton' 
first 
second 
'isaac' 
'isaac newton' 
Python Aliasing
But lists are mutable 
Python Aliasing
But lists are mutable 
first = ['isaac'] 
vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee 
first 
'isaac' 
Python Aliasing
But lists are mutable 
first = ['isaac'] 
second = first 
vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee 
first 
second 
'isaac' 
Python Aliasing
But lists are mutable 
first = ['isaac'] 
second = first 
first = first.append('newton') 
pppprrrriiiinnnntttt first 
['isaac', 'newton'] 
vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee 
first 
second 
'isaac' 'newton' 
Python Aliasing
But lists are mutable 
first = ['isaac'] 
second = first 
first = first.append('newton') 
pppprrrriiiinnnntttt first 
['isaac', 'newton'] 
pppprrrriiiinnnntttt second 
['isaac', 'newton'] 
vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee 
first 
second 
'isaac' 'newton' 
Python Aliasing
But lists are mutable 
first = ['isaac'] 
second = first 
first = first.append('newton') 
pppprrrriiiinnnntttt first 
['isaac', 'newton'] 
pppprrrriiiinnnntttt second 
['isaac', 'newton'] 
vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee 
first 
Didn't explicitly 
second 
'isaac' 'newton' 
modify second 
Python Aliasing
But lists are mutable 
first = ['isaac'] 
second = first 
first = first.append('newton') 
pppprrrriiiinnnntttt first 
['isaac', 'newton'] 
pppprrrriiiinnnntttt second 
['isaac', 'newton'] 
vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee 
first 
Didn't explicitly 
second 
'isaac' 'newton' 
modify second 
A side effect 
Python Aliasing
Example: use lists of lists 
to implement a 2D grid 
Python Aliasing
3 
5 
Example: use lists of lists 
to implement a 2D grid 
7 
2 
6 
5 
7 5 8 
5 6 3 
3 2 4 
4 
3 
8 
Python Aliasing
3 
5 
Example: use lists of lists 
to implement a 2D grid 
7 
2 
6 
5 
7 5 8 
5 6 3 
3 2 4 
grid 
4 
3 
8 
Python Aliasing
3 
5 
Example: use lists of lists 
to implement a 2D grid 
7 
2 
6 
5 
7 5 8 
5 6 3 
3 2 4 
grid[0] 
4 
3 
8 
Python Aliasing
3 
5 
Example: use lists of lists 
to implement a 2D grid 
7 
2 
6 
5 
7 5 8 
5 6 3 
3 2 4 
grid[0][1] 
4 
3 
8 
Python Aliasing
# Correct code 
grid = [] 
ffffoooorrrr x iiiinnnn range(N): 
temp = [] 
ffffoooorrrr y iiiinnnn range(N): 
temp.append(1) 
grid.append(temp) 
Python Aliasing
# Correct code 
grid = [] 
ffffoooorrrr x iiiinnnn range(N): 
temp = [] 
Outer "spine" of structure 
ffffoooorrrr y iiiinnnn range(N): 
temp.append(1) 
grid.append(temp) 
Python Aliasing
# Correct code 
grid = [] 
ffffoooorrrr x iiiinnnn range(N): 
temp = [] 
ffffoooorrrr y iiiinnnn range(N): 
temp.append(1) 
grid.append(temp) 
Add N sub-lists to outer list 
Python Aliasing
# Correct code 
grid = [] 
ffffoooorrrr x iiiinnnn range(N): 
temp = [] 
ffffoooorrrr y iiiinnnn range(N): 
temp.append(1) 
grid.append(temp) 
Create a sublist of N 1's 
Python Aliasing
# Equivalent code 
grid = [] 
ffffoooorrrr x iiiinnnn range(N): 
grid.append([]) 
ffffoooorrrr y iiiinnnn range(N): 
grid[-1].append(1) 
Python Aliasing
# Equivalent code 
grid = [] 
ffffoooorrrr x iiiinnnn range(N): 
grid.append([]) 
ffffoooorrrr y iiiinnnn range(N): 
grid[-1].append(1) 
Last element of outer list is the sublist currently 
being filled in 
Python Aliasing
# Incorrect code 
grid = [] 
EMPTY = [] 
ffffoooorrrr x iiiinnnn range(N): 
grid.append(EMPTY) 
ffffoooorrrr y iiiinnnn range(N): 
grid[-1].append(1) 
Python Aliasing
# Incorrect code 
grid = [] 
EMPTY = [] 
ffffoooorrrr x iiiinnnn range(N): 
# Equivalent code 
grid = [] 
ffffoooorrrr x iiiinnnn range(N): 
grid.append(EMPTY) 
ffffoooorrrr y iiiinnnn range(N): 
grid[-1].append(1) 
grid.append([]) 
ffffoooorrrr y iiiinnnn range(N): 
grid[-1].append(1) 
Python Aliasing
# Incorrect code 
grid = [] 
EMPTY = [] 
ffffoooorrrr x iiiinnnn range(N): 
Aren't meaningful variable 
names supposed to be 
grid.append(EMPTY) 
ffffoooorrrr y iiiinnnn range(N): 
grid[-1].append(1) 
a good thing? 
Python Aliasing
vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee 
grid = [] 
EMPTY = [] 
ffffoooorrrr x iiiinnnn range(N): 
x 0 
grid.append(EMPTY) 
ffffoooorrrr y iiiinnnn range(N): 
grid[-1].append(1) 
grid 
EMPTY 
Python Aliasing
vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee 
grid = [] 
EMPTY = [] 
ffffoooorrrr x iiiinnnn range(N): 
x 0 
grid.append(EMPTY) 
ffffoooorrrr y iiiinnnn range(N): 
grid[-1].append(1) 
grid 
EMPTY 
Python Aliasing
vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee 
grid = [] 
EMPTY = [] 
ffffoooorrrr x iiiinnnn range(N): 
x 
y 
0 
0 
grid.append(EMPTY) 
ffffoooorrrr y iiiinnnn range(N): 
grid[-1].append(1) 
grid 
EMPTY 
Python Aliasing
vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee 
grid = [] 
EMPTY = [] 
ffffoooorrrr x iiiinnnn range(N): 
x 
y 
0 
0 
grid.append(EMPTY) 
ffffoooorrrr y iiiinnnn range(N): 
grid[-1].append(1) 
grid 
EMPTY 
1 
Python Aliasing
vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee 
grid = [] 
EMPTY = [] 
ffffoooorrrr x iiiinnnn range(N): 
x 
y 
0 
2 
grid.append(EMPTY) 
ffffoooorrrr y iiiinnnn range(N): 
grid[-1].append(1) 
grid 
EMPTY 
1 1 1 
Python Aliasing
vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee 
grid = [] 
EMPTY = [] 
ffffoooorrrr x iiiinnnn range(N): 
x 
y 
1 
2 
grid.append(EMPTY) 
ffffoooorrrr y iiiinnnn range(N): 
grid[-1].append(1) 
grid 
EMPTY 
1 1 1 
Python Aliasing
vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee 
grid = [] 
EMPTY = [] 
ffffoooorrrr x iiiinnnn range(N): 
x 
y 
1 
2 
grid.append(EMPTY) 
ffffoooorrrr y iiiinnnn range(N): 
grid[-1].append(1) 
grid 
EMPTY 
1 1 1 
You see the problem... 
Python Aliasing
No Aliasing 
ffiirrsstt == [[]] 
second = [] 
Python Aliasing
No Aliasing Aliasing 
ffiirrsstt == [[]] ffiirrsstt == [[]] 
second = [] second = first 
Python Aliasing
vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee 
grid = [] 
ffffoooorrrr x iiiinnnn range(N): 
grid.append([]) 
x 0 
ffffoooorrrr y iiiinnnn range(N): 
grid[-1].append(1) 
grid 
Python Aliasing
vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee 
grid = [] 
ffffoooorrrr x iiiinnnn range(N): 
grid.append([]) 
x 0 
ffffoooorrrr y iiiinnnn range(N): 
grid[-1].append(1) 
grid 
Python Aliasing
vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee 
grid = [] 
ffffoooorrrr x iiiinnnn range(N): 
grid.append([]) 
x 
y 
0 
2 
ffffoooorrrr y iiiinnnn range(N): 
grid[-1].append(1) 
grid 
1 1 1 
Python Aliasing
vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee 
grid = [] 
ffffoooorrrr x iiiinnnn range(N): 
grid.append([]) 
x 
y 
1 
2 
ffffoooorrrr y iiiinnnn range(N): 
grid[-1].append(1) 
grid 
1 1 1 
Python Aliasing
vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee 
grid = [] 
ffffoooorrrr x iiiinnnn range(N): 
grid.append([]) 
x 
y 
1 
0 
ffffoooorrrr y iiiinnnn range(N): 
grid[-1].append(1) 
grid 
1 1 1 
1 
Python Aliasing
If aliasing can cause bugs, why allow it? 
Python Aliasing
If aliasing can cause bugs, why allow it? 
1. Some languages don't 
Python Aliasing
If aliasing can cause bugs, why allow it? 
1. Some languages don't 
Or at lleeaasstt aappppeeaarr nnoott ttoo 
Python Aliasing
If aliasing can cause bugs, why allow it? 
1. Some languages don't 
Or at lleeaasstt aappppeeaarr nnoott ttoo 
2. Aliasing a million-element list is more efficient 
than copying it 
Python Aliasing
If aliasing can cause bugs, why allow it? 
1. Some languages don't 
Or at lleeaasstt aappppeeaarr nnoott ttoo 
2. Aliasing a million-element list is more efficient 
than copying it 
3. Sometimes really do want to update a structure 
in place 
Python Aliasing
created by 
Greg Wilson 
October 2010 
Copyright © Software Carpentry 2010 
This work is licensed under the Creative Commons Attribution License 
See http://software-carpentry.org/license.html for more information.

Alias

  • 1.
    Python Aliasing Copyright© Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See http://software-carpentry.org/license.html for more information.
  • 2.
    An alias isa second name for a piece of data Python Aliasing
  • 3.
    An alias isa second name for a piece of data Often easier (and more useful) than making a sseeccoonndd ccooppyy Python Aliasing
  • 4.
    An alias isa second name for a piece of data Often easier (and more useful) than making a sseeccoonndd ccooppyy If the data is immutable, aliases don't matter Python Aliasing
  • 5.
    An alias isa second name for a piece of data Often easier (and more useful) than making a sseeccoonndd ccooppyy If the data is immutable, aliases don't matter Because the data can't change Python Aliasing
  • 6.
    An alias isa second name for a piece of data Often easier (and more useful) than making a sseeccoonndd ccooppyy If the data is immutable, aliases don't matter Because the data can't change But if data can change, aliases can result in a lot of hard-to-find bugs Python Aliasing
  • 7.
    Aliasing happens wheneverone variable's value is assigned to another variable Python Aliasing
  • 8.
    Aliasing happens wheneverone variable's value is assigned to another variable first = 'isaac' vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee first 'isaac' Python Aliasing
  • 9.
    Aliasing happens wheneverone variable's value is assigned to another variable first = 'isaac' second = first vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee first second 'isaac' Python Aliasing
  • 10.
    Aliasing happens wheneverone variable's value is assigned to another variable first = 'isaac' second = first But as we've already seen… vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee first second 'isaac' Python Aliasing
  • 11.
    Aliasing happens wheneverone variable's value is assigned to another variable first = 'isaac' second = first But as we've already seen… vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee first = first + ' newton' first second 'isaac' 'isaac newton' Python Aliasing
  • 12.
    But lists aremutable Python Aliasing
  • 13.
    But lists aremutable first = ['isaac'] vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee first 'isaac' Python Aliasing
  • 14.
    But lists aremutable first = ['isaac'] second = first vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee first second 'isaac' Python Aliasing
  • 15.
    But lists aremutable first = ['isaac'] second = first first = first.append('newton') pppprrrriiiinnnntttt first ['isaac', 'newton'] vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee first second 'isaac' 'newton' Python Aliasing
  • 16.
    But lists aremutable first = ['isaac'] second = first first = first.append('newton') pppprrrriiiinnnntttt first ['isaac', 'newton'] pppprrrriiiinnnntttt second ['isaac', 'newton'] vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee first second 'isaac' 'newton' Python Aliasing
  • 17.
    But lists aremutable first = ['isaac'] second = first first = first.append('newton') pppprrrriiiinnnntttt first ['isaac', 'newton'] pppprrrriiiinnnntttt second ['isaac', 'newton'] vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee first Didn't explicitly second 'isaac' 'newton' modify second Python Aliasing
  • 18.
    But lists aremutable first = ['isaac'] second = first first = first.append('newton') pppprrrriiiinnnntttt first ['isaac', 'newton'] pppprrrriiiinnnntttt second ['isaac', 'newton'] vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee first Didn't explicitly second 'isaac' 'newton' modify second A side effect Python Aliasing
  • 19.
    Example: use listsof lists to implement a 2D grid Python Aliasing
  • 20.
    3 5 Example:use lists of lists to implement a 2D grid 7 2 6 5 7 5 8 5 6 3 3 2 4 4 3 8 Python Aliasing
  • 21.
    3 5 Example:use lists of lists to implement a 2D grid 7 2 6 5 7 5 8 5 6 3 3 2 4 grid 4 3 8 Python Aliasing
  • 22.
    3 5 Example:use lists of lists to implement a 2D grid 7 2 6 5 7 5 8 5 6 3 3 2 4 grid[0] 4 3 8 Python Aliasing
  • 23.
    3 5 Example:use lists of lists to implement a 2D grid 7 2 6 5 7 5 8 5 6 3 3 2 4 grid[0][1] 4 3 8 Python Aliasing
  • 24.
    # Correct code grid = [] ffffoooorrrr x iiiinnnn range(N): temp = [] ffffoooorrrr y iiiinnnn range(N): temp.append(1) grid.append(temp) Python Aliasing
  • 25.
    # Correct code grid = [] ffffoooorrrr x iiiinnnn range(N): temp = [] Outer "spine" of structure ffffoooorrrr y iiiinnnn range(N): temp.append(1) grid.append(temp) Python Aliasing
  • 26.
    # Correct code grid = [] ffffoooorrrr x iiiinnnn range(N): temp = [] ffffoooorrrr y iiiinnnn range(N): temp.append(1) grid.append(temp) Add N sub-lists to outer list Python Aliasing
  • 27.
    # Correct code grid = [] ffffoooorrrr x iiiinnnn range(N): temp = [] ffffoooorrrr y iiiinnnn range(N): temp.append(1) grid.append(temp) Create a sublist of N 1's Python Aliasing
  • 28.
    # Equivalent code grid = [] ffffoooorrrr x iiiinnnn range(N): grid.append([]) ffffoooorrrr y iiiinnnn range(N): grid[-1].append(1) Python Aliasing
  • 29.
    # Equivalent code grid = [] ffffoooorrrr x iiiinnnn range(N): grid.append([]) ffffoooorrrr y iiiinnnn range(N): grid[-1].append(1) Last element of outer list is the sublist currently being filled in Python Aliasing
  • 30.
    # Incorrect code grid = [] EMPTY = [] ffffoooorrrr x iiiinnnn range(N): grid.append(EMPTY) ffffoooorrrr y iiiinnnn range(N): grid[-1].append(1) Python Aliasing
  • 31.
    # Incorrect code grid = [] EMPTY = [] ffffoooorrrr x iiiinnnn range(N): # Equivalent code grid = [] ffffoooorrrr x iiiinnnn range(N): grid.append(EMPTY) ffffoooorrrr y iiiinnnn range(N): grid[-1].append(1) grid.append([]) ffffoooorrrr y iiiinnnn range(N): grid[-1].append(1) Python Aliasing
  • 32.
    # Incorrect code grid = [] EMPTY = [] ffffoooorrrr x iiiinnnn range(N): Aren't meaningful variable names supposed to be grid.append(EMPTY) ffffoooorrrr y iiiinnnn range(N): grid[-1].append(1) a good thing? Python Aliasing
  • 33.
    vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee grid= [] EMPTY = [] ffffoooorrrr x iiiinnnn range(N): x 0 grid.append(EMPTY) ffffoooorrrr y iiiinnnn range(N): grid[-1].append(1) grid EMPTY Python Aliasing
  • 34.
    vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee grid= [] EMPTY = [] ffffoooorrrr x iiiinnnn range(N): x 0 grid.append(EMPTY) ffffoooorrrr y iiiinnnn range(N): grid[-1].append(1) grid EMPTY Python Aliasing
  • 35.
    vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee grid= [] EMPTY = [] ffffoooorrrr x iiiinnnn range(N): x y 0 0 grid.append(EMPTY) ffffoooorrrr y iiiinnnn range(N): grid[-1].append(1) grid EMPTY Python Aliasing
  • 36.
    vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee grid= [] EMPTY = [] ffffoooorrrr x iiiinnnn range(N): x y 0 0 grid.append(EMPTY) ffffoooorrrr y iiiinnnn range(N): grid[-1].append(1) grid EMPTY 1 Python Aliasing
  • 37.
    vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee grid= [] EMPTY = [] ffffoooorrrr x iiiinnnn range(N): x y 0 2 grid.append(EMPTY) ffffoooorrrr y iiiinnnn range(N): grid[-1].append(1) grid EMPTY 1 1 1 Python Aliasing
  • 38.
    vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee grid= [] EMPTY = [] ffffoooorrrr x iiiinnnn range(N): x y 1 2 grid.append(EMPTY) ffffoooorrrr y iiiinnnn range(N): grid[-1].append(1) grid EMPTY 1 1 1 Python Aliasing
  • 39.
    vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee grid= [] EMPTY = [] ffffoooorrrr x iiiinnnn range(N): x y 1 2 grid.append(EMPTY) ffffoooorrrr y iiiinnnn range(N): grid[-1].append(1) grid EMPTY 1 1 1 You see the problem... Python Aliasing
  • 40.
    No Aliasing ffiirrsstt== [[]] second = [] Python Aliasing
  • 41.
    No Aliasing Aliasing ffiirrsstt == [[]] ffiirrsstt == [[]] second = [] second = first Python Aliasing
  • 42.
    vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee grid= [] ffffoooorrrr x iiiinnnn range(N): grid.append([]) x 0 ffffoooorrrr y iiiinnnn range(N): grid[-1].append(1) grid Python Aliasing
  • 43.
    vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee grid= [] ffffoooorrrr x iiiinnnn range(N): grid.append([]) x 0 ffffoooorrrr y iiiinnnn range(N): grid[-1].append(1) grid Python Aliasing
  • 44.
    vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee grid= [] ffffoooorrrr x iiiinnnn range(N): grid.append([]) x y 0 2 ffffoooorrrr y iiiinnnn range(N): grid[-1].append(1) grid 1 1 1 Python Aliasing
  • 45.
    vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee grid= [] ffffoooorrrr x iiiinnnn range(N): grid.append([]) x y 1 2 ffffoooorrrr y iiiinnnn range(N): grid[-1].append(1) grid 1 1 1 Python Aliasing
  • 46.
    vvvvaaaarrrriiiiaaaabbbblllleeee vvvvaaaalllluuuueeee grid= [] ffffoooorrrr x iiiinnnn range(N): grid.append([]) x y 1 0 ffffoooorrrr y iiiinnnn range(N): grid[-1].append(1) grid 1 1 1 1 Python Aliasing
  • 47.
    If aliasing cancause bugs, why allow it? Python Aliasing
  • 48.
    If aliasing cancause bugs, why allow it? 1. Some languages don't Python Aliasing
  • 49.
    If aliasing cancause bugs, why allow it? 1. Some languages don't Or at lleeaasstt aappppeeaarr nnoott ttoo Python Aliasing
  • 50.
    If aliasing cancause bugs, why allow it? 1. Some languages don't Or at lleeaasstt aappppeeaarr nnoott ttoo 2. Aliasing a million-element list is more efficient than copying it Python Aliasing
  • 51.
    If aliasing cancause bugs, why allow it? 1. Some languages don't Or at lleeaasstt aappppeeaarr nnoott ttoo 2. Aliasing a million-element list is more efficient than copying it 3. Sometimes really do want to update a structure in place Python Aliasing
  • 52.
    created by GregWilson October 2010 Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See http://software-carpentry.org/license.html for more information.