assignment in python
<p>I know that "variable assignment" in python is in fact a binding / re-bindign of a name (the variable) to an object. </p>

<p>This brings the question: is it possible to have proper assignment in python, eg make an object equal to another object?</p>

<p>I guess there is no need for that in python:</p>

<ol>
<li><p>Inmutable objects cannot be 'assigned to' since they can't be changed</p></li>
<li><p>Mutable objects could potentially be assigned to, since they can change, and this could be useful, since you may want to manipulate a copy of dictionary separately from the original one. However, in these cases the python philosophy is to offer a cloning method on the mutable object, so you can bind a copy rather than the original. </p></li>
</ol>

<p>So I guess the answer is that there is no assignment in python, the best way to mimic it would be binding to a cloned object</p>

<p>I simply wanted to share the question in case I'm missing something important here</p>

<p>Thanks</p>

<p><strong>EDIT:</strong> </p>

<p>Both Lie Ryan and Sven Marnach answers are good, I guess the overall answer is a mix of both: </p>

<p>For user defined types, use the idiom: </p>

<blockquote>
  <p>a.<strong>dict</strong> = dict(b.<strong>dict</strong>)</p>
</blockquote>

<p>(I guess this has problems as well if the assigned class has redefined attribute access methods, but lets not be fussy :))</p>

<p>For mutable built-ins (lists and dicts) use the cloning / copying methods they provide (eg slices, update)</p>

<p>finally inmutable built-ins can't be changed so can't be assigned</p>

<p>I'll choose Lie Ryan because it's an elegant idiom that I hadn't thought of.</p>

<p>Thanks!</p>
