New submission from Ram Rachum: Can't this code:
class Sequence(Sized, Iterable, Container): # ... def __contains__(self, value): for v in self: if v == value: return True return False Be shortened into this: class Sequence(Sized, Iterable, Container): # ... def __contains__(self, value): return any(item == value for value in self) Which can even fit on one line with a lambda: class Sequence(Sized, Iterable, Container): # ... __contains__ = lambda self: any(item == value for value in self) ---------- components: Library (Lib) messages: 227117 nosy: cool-RR priority: normal severity: normal status: open title: Shortening code in abc.py versions: Python 3.5 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue22446> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com