<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="font-family: 'times new roman'; font-size: 16px; ">So the problem is that when I change bb, aa also changes even</span><div><span class="Apple-style-span" style="font-family: 'times new roman'; font-size: 16px; ">though I don't want it to. Is this supposed to happen?</span></div><div><font class="Apple-style-span" face="'times new roman'" size="4"><span class="Apple-style-span" style="font-size: 16px;"><br class="webkit-block-placeholder"></span></font></div><div><span class="Apple-style-span" style="font-family: 'times new roman'; font-size: 16px; "> Yes </span></div><div><font class="Apple-style-span" face="'times new roman'" size="4"><span class="Apple-style-span" style="font-size: 16px;"><br class="webkit-block-placeholder"></span></font></div><div>Names are handles for objects. Assignment binds</div><div><div><div>a name to an object. The same object can be</div><div>bound simultaneously to many names.</div><div><br class="webkit-block-placeholder"></div><div>Python distinguishes between equality and identity, so</div><div>there are two comparison operators: '==' and 'is'. Objects</div><div>are equal if they have the same value (==) but they are</div><div>identical only if they refer to the same object (is).</div><div><br class="webkit-block-placeholder"></div><div><div>The constructor expressions [], {}, and () produce</div><div>new objects.</div><div><br></div></div><div><div>>>> [1, 2] == [1, 2] # same value</div><div>True</div><div>>>> [1, 2] is [1, 2] # but different lists</div><div>False</div><div><br class="webkit-block-placeholder"></div><div><div>>>> a = [1, 2] # this is assigned to a new list</div><div>>>> b = [1, 2] # this is also assigned to a new list</div><div>>>> a == b # the lists have the same value</div><div>True</div><div>>>> a is b # but they are not the same list</div><div>False</div><div><br class="webkit-block-placeholder"></div><div><div>>>> a = [1, 2] # assign to a new list</div><div>>>> b = a # attach the list in a to a new name</div><div>>>> a == b # they have the same value</div><div>True</div><div><div>>>> a is b # because they are the same list</div><div>True</div><div><br class="webkit-block-placeholder"></div><div>The list(FOO) function copies an list.</div><div><br class="webkit-block-placeholder"></div><div><div>>>> a = [1, 2] # new list</div><div>>>> b = list(a) # make a copy of the list in b</div><div>>>> a == b # the original and copy are equal</div><div>True</div><div>>>> a is b # but they are not the same list</div><div>False</div></div></div></div></div></div><div><br class="webkit-block-placeholder"></div><div><br></div><div><div><div><br><div apple-content-edited="true"> <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>- Jeff Younker - <a href="mailto:jeff@drinktomi.com">jeff@drinktomi.com</a> -</div></div><br class="Apple-interchange-newline"></span></div></span><br class="Apple-interchange-newline"> </div><br></div></div></div></div></div></body></html>