very good reasons?

François Pinard pinard at iro.umontreal.ca
Sun Oct 1 18:28:44 EDT 2000


[Kragen Sitaker]

> You write:
> > I'm not sure that `y = list(x)' returns `y' different than `x', if `x' is
> > already a list, in which case the functions above would mutate operands,
> > which is not welcome.  Maybe (?) it would be safer to write:

> It does return a copy of x if x is a list in 1.5.2.  Your proposed
> solution unfortunately doesn't work for tuples, which is unperlish.

> > 	y = x[:]

My suggestion about x[:] was not good.  Thanks for correcting me, Kragen.

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard




More information about the Python-list mailing list