On Oct 17, 9:49 pm, a...@pythoncraft.com (Aahz) wrote: > Ahhh, I vaguely remember there being some discussion of this when sum() > was introduced -- I think that using InPlaceAdd would have caused bad > behavior when the initial list was referred to by multiple names.
Ah yes. Good point. With my one-line modification, I get: Python 2.7a0 (trunk:75468M, Oct 17 2009, 21:57:02) [GCC 4.0.1 (Apple Inc. build 5493)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> acc = [] >>> sum(([i] for i in range(10)), acc) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> acc [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] There should probably be a test for this somewhere, to make sure that no-one else is tempted to make this change. -- Mark -- http://mail.python.org/mailman/listinfo/python-list