incrementation operators?
Peter Schneider-Kamp
nowonder at nowonder.de
Mon Aug 14 10:16:05 EDT 2000
Thomas Wouters wrote:
>
> On Sun, Aug 13, 2000 at 08:42:08PM -0400, Colin J. Williams wrote:
> >
> > Suppose one wishes to do a.append([5]). It would appear that one would have to
> > return to the existing syntax.
You'll have to do:
a += [[5]]
> "a += 3" isn't equivalent to a.append(3), it's equivalent to
> 'a.extend(3)'. But you can write 'a.append(3)' as 'a.append([3])', and it's
^^^^^^^^^^^^^
I am sure you meant: a.extend([3])
> solved :-) You might have missed that in my original posting: I did say you
> could use augmented assignment in place of 'append' and 'extend', but my
> example had that extra pair of brackets you need to make it work.
Yes.
Peter
--
Peter Schneider-Kamp ++47-7388-7331
Herman Krags veg 51-11 mailto:peter at schneider-kamp.de
N-7050 Trondheim http://schneider-kamp.de
More information about the Python-list
mailing list