This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steven.daprano
Recipients Roee Nizan, brett.cannon, serhiy.storchaka, steven.daprano, vstinner, wolma
Date 2019-08-21.11:10:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
In-reply-to <>
On Wed, Aug 21, 2019 at 10:51:02AM +0000, STINNER Victor wrote:

> Rather than adding a new function, why not adding a parameter like 
> sort(key=func, reverse=True)? Something like fnmatch.filterfalse(pat, 
> invert=True)?

Guido argues that as a general rule of thumb, we should avoid "constant 
bool parameters" and prefer seperate functions. For example, we have

- and re.match, not

- str.find and str.rfind, not str.find(end=False)

If we typically call the function with a bool constant:

    filter(pat, invert=True)

rather than a variable or expression

    filter(pat, invert=condition or default)

that's a hint that the two cases probably should be seperate functions.

Martin Fowler agrees:

as does Raymond Chen:

(Of course there are cases where it is impractical to avoid bool flags 
-- if a function would otherwise take four flags, we would need sixteen 
functions! -- or there may be other reasons why we might go against that 
design rule.)
Date User Action Args
2019-08-21 11:10:49steven.dapranosetrecipients: + steven.daprano, brett.cannon, vstinner, serhiy.storchaka, wolma, Roee Nizan
2019-08-21 11:10:49steven.dapranolinkissue30413 messages
2019-08-21 11:10:49steven.dapranocreate