[Python-ideas] Changing all() and any() to take multiple arguments

Clay Sweetser clay.sweetser at gmail.com
Mon Aug 26 06:50:17 CEST 2013


I believe that the all() and any() library functions should be modified to
accept multiple arguments as well as single iterators.

Currently, code such as this (taken from a sublime text plugin), breaks:
    def is_enabled(self):
        return all(
            self.connected,
            not self.broadcasting,
            self.mode is 'client'
        )

Meaning either that one must write either this, and use parenthesis to
avoid some obscure order of operations error:
    def is_enabled(self):
        return (
            (self.connected) and
            (not self.broadcasting) and
            (self.mode is 'client')
        )

Or this, and have others wonder at the odd double parenthesis or list:
    def is_enabled(self):
        return ((
            self.connected,
            not self.broadcasting,
            self.mode is 'client'
        ))

I can't foresee any compatibility issues for this modification, as it would
only make currently broken code work, not the other way around.

I searched the mailing list archives with Google to see if there were any
past discussions on this topic, however the  ambiguousness my search terms
('all', 'any' 'multiple, 'arguments') meant that the results were too
numerous for me to sort through ( I gave up after the first 3 pages).

Clay Sweetser

"The trouble with having an open mind, of course, is that people will
insist on coming along and trying to put things in it. " - Terry Pratchett
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130826/420bc5f5/attachment.html>


More information about the Python-ideas mailing list