[Python-ideas] list…pushed, or something

Cameron Simpson cs at zip.com.au
Thu Mar 28 05:27:48 CET 2013

On 27Mar2013 19:29, Shane Green <shane at umbrellacode.com> wrote:
| I'm not sure if there's anything inherently wrong with this idea, and I am well aware
| how incredibly easy it is to implement as an extension of the built-ins, but, I find it
| very useful to have variations of list().append(obj) and set().add(obj) that return,
| obj.  I've never come up with perfect method names; sometimes I go with past-tense
| versions, "added" and "appended" (or "pushed").  I often use these methods in places
| where performance is  a factor, such as using a set() to filter repeats from an input
| sequence.

I don't suppose you could post example code?

I suspect the thinking goes that functions/methods that do something
shouldn't just be "identity" functions where f(x) == x. And if they
are defined to be identity functions you may as well return None,
since the calling code isn't learning anything new.

At any rate, that would be part of my thinking, and for me it is
enough to not favour the proposal without a better demo of where
it is a win, or of how horribly I have misconstrued your suggestion.


If everyone is thinking alike, then someone isn't thinking.     - Patton

More information about the Python-ideas mailing list