Aliasing

Python > Aliasing
https://docs.python.org/3.5/tutorial/classes.html

see the “tricks” list in the class “Dog”

side effect

# Create a
a = [5]

# Create a new with the same value
b = list(a)

# Same with the full slice technique:
b = a[:]

# print a,b
print( id(a), id(b))

cited by:
An Introduction to Interactive Programming in Python (Part 2)

Coursera. Rice University. October 2015
https://www.coursera.org/course/interactivepython2

aliasing1of2Inside the function, p is an alias for blank, so if the function modifies p, blank changes.
p. 273
Think Python 2e
©2016
by Allen B. Downey
http://greenteapress.com/wp/think-python-2e
aliasing2of2

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s