[Python-ideas] set.add() return value

Raymond Hettinger python at rcn.com
Tue Feb 17 06:27:02 CET 2009


[Greg Ewing]
> I think there could be some theoretical justification
> to do it for sets at least. The pattern of "if something
> isn't already in some set, then add it and do some further
> processing" turns up fairly frequently in various algorithms.

If we have to do this, then a separate method with
a very clear name is better than mucking-up the signature
for set.add() and set.discard().

Of course, we don't have to do this.  It saves only one line.


Raymond



More information about the Python-ideas mailing list