Suggestions for 2002

Richard Jones richardjones at optushome.com.au
Sun Jan 13 00:02:44 EST 2002


On Sun, 13 Jan 2002 15:43, Paul Rubin wrote:
> "Mark McEahern" <marklists at mceahern.com> writes:
> > What would you expect here (breaking the multiple assignment up into
> > separate assignment)?
> >
> > >>> a = ['cat','dog']
> > >>> i = 1
> > >>> i = 0
> > >>> a[i] = 'boo'
> > >>> a
> >
> > Clearly, you'd expect ['boo', 'dog'].
> >
> > So where's the problem?
>
> I'd expect a,b = c,d  to work as something like:
>
>   temp1 = c
>   temp2 = d
>   a = temp1
>   b = temp2

or, using the data structures from the original post and the example above,

>>> a = ['cat', 'dog']
>>> i = 1
>>> temp1 = 0
>>> temp2 = 'boo'
>>> i = temp1
>>> a[i] = temp2
>>> a
['boo', 'dog']

... how is this not working correctly?


    Richard




More information about the Python-list mailing list