[Tutor] two ways

Shi Mu samrobertsmith at gmail.com
Fri Nov 11 08:56:03 CET 2005


thanks!

On 11/10/05, Liam Clarke <ml.cyresse at gmail.com> wrote:
> 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