Suggestions for 2002

Richard Jones richardjones at optushome.com.au
Sun Jan 13 01:00:31 EST 2002


On Sun, 13 Jan 2002 16:17, Paul Rubin wrote:
> Richard Jones <richardjones at optushome.com.au> writes:
> > > 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?
>
> Oops, lemme try again.  The idea is that a,b=c,d is supposed to
> simulate doing the assignments in parallel.  So I'd expect a,b = c,d
> to work as something like (using C-style pointer notation):

... having to resort to using a pointer notation merely reinforces my feeling 
that you're not thinking about the problem in a very Pythonesque way. Python 
doesn't have the pointer/scalar split that other languages seem so burdened 
by (hello, C and *blech* Perl). There's just labels on values. The left hand 
side of an assignment operation defines what labels are being applied to the 
right hand side of an operation. No pointers, no magic...


     Richard




More information about the Python-list mailing list