[Python-Dev] PEP 428: Pathlib -> stat caching
Stephen J. Turnbull
stephen at xemacs.org
Tue Sep 17 02:34:39 CEST 2013
Terry Reedy writes:
> On 9/16/2013 4:14 PM, R. David Murray wrote:
>
> > Well, we tend to avoid single boolean arguments in favor of differently
> > named functions.
>
> The stdlib has lots of boolean arguments. My impression is that they are
> to be avoided when they would change the return type or otherwise do
> something disjointly different. I do not think this would apply here.
I remember reading that the criterion is whether the argument is most
often given a literal value. Then "stat_cache()" is preferable to
"stat(cache=True)". OTOH, "stat(cache=want_cache)" is better than
if want_cache:
result = stat_cache()
else:
result = stat()
or "result = stat_cache() if want_cache else stat()".
More information about the Python-Dev
mailing list