[Python-ideas] Alternative spelling for list.append()
Steven D'Aprano
steve at pearwood.info
Mon Jun 18 20:23:33 EDT 2018
On Mon, Jun 18, 2018 at 05:07:45PM -0300, Joao S. O. Bueno wrote:
> a = [1,2, 3]
> a <<= 4
> resulting in a == [1, 2, 3, 4] is quite readable
Not as readable as a.append(4), which works today and doesn't require
the user to memorise the special case that <<= works on lists but
(presumably) << doesn't.
Or perhaps it would. What would a bare << mean for lists?
b = a << 4
could mean the same as
b = a + [4]
but we already have a spelling for that, do we really need another one?
--
Steve
More information about the Python-ideas
mailing list