[New-bugs-announce] [issue22879] Make set's add and discard methods return useful information

Brecht Machiels report at bugs.python.org
Sat Nov 15 23:47:49 CET 2014


New submission from Brecht Machiels:

set's add() method would be a little bit more useful if it would return True if the added value was already present in the set, and False if it wasn't (or the other way around). Similarly, discard() could report whether the discarded value was present in the set or not.

I suppose this could cost a couple of extra cycles and I'm not sure this is acceptable. For discard() there's always remove() that offers similar behavior. add() does not have an alternative that offers check-and-add behavior.

----------
components: Library (Lib)
messages: 231226
nosy: brechtm
priority: normal
severity: normal
status: open
title: Make set's add and discard methods return useful information
type: enhancement
versions: Python 3.5, Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22879>
_______________________________________


More information about the New-bugs-announce mailing list