[Tutor] two ways

Liam Clarke ml.cyresse at gmail.com
Fri Nov 11 08:50:30 CET 2005


Hi Shi,

For what you're doing, nothing at all.

When you use a colon, slice syntax, it defaults to [start:end] so p =
a[:] is the same as
p = a[0:len(a)]

Regards,

Liam Clarke

On 11/11/05, Shi Mu <samrobertsmith at gmail.com> wrote:
> what is the difference between the two ways of assigning the list?
> p=a vs. p=a[:]
> >>> a=range(5)
> >>> a
> [0, 1, 2, 3, 4]
> >>> p=a
> >>> p
> [0, 1, 2, 3, 4]
> >>> p=a[:]
> >>> p
> [0, 1, 2, 3, 4]
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list