Strange behavior related to value / reference

Aahz aahz at pythoncraft.com
Fri Oct 30 16:32:29 EDT 2009


In article <626f24e5-4d8e-416c-b3ed-dc56a88dc35b at s21g2000prm.googlegroups.com>,
Lambda  <stephenhsu9 at gmail.com> wrote:
>
>def matrix_power(m, n):
>  result = m[:]
>  print result is m

Use copy.deepcopy()
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"You could make Eskimos emigrate to the Sahara by vigorously arguing --
at hundreds of screens' length -- for the wonder, beauty, and utility of
snow."  --PNH to rb in r.a.sf.f



More information about the Python-list mailing list