[Tutor] creating a list of data . . .

Don Arnold darnold02 at sprynet.com
Mon Aug 25 21:58:21 EDT 2003


----- Original Message -----
From: "Gus Tabares" <gus.tabares at verizon.net>
To: <tutor at python.org>
Sent: Monday, August 25, 2003 8:35 PM
Subject: Re: [Tutor] creating a list of data . . .


> On Mon, 2003-08-25 at 21:29, Kirk Bailey wrote:
> > Tuples are immutable. That means they cannot be changed, they can only
be
> > created or destroyed.
> >
> > So do so. Kill it. and create it. In the process of creating it anew, do
so with
> > the extra data thrown in. A temporary variable would probably  be a good
idea
> > here to hold the old content of your tuple.
>
> Hello,
>
> Concatenation is perfectly legal:
>

True, but the rebinding it entails is inefficient.

> >>> tuple = (1, 2, 3, 4)
> >>> tuple = tuple + (5, 6, 7, 8)
> >>> tuple
> (1, 2, 3, 4, 5, 6, 7, 8)
> >>>
>

And rebinding a built in type (as was done with here 'tuple'), is equally
legal, but _never_ a good idea.

>
> HTH,
>
> --
> /Gus

Ditto,
Don




More information about the Tutor mailing list