On Tue, May 10, 2016 at 6:15 AM, Joseph Martinot-Lagarde <contrebasse@gmail.com> wrote:
Serhiy Storchaka <storchaka@...> writes:

> 1. It is preferable to pass boolean arguments as keyword arguments (if
> this is not the only argument).
>
> 2. It is preferable to declare boolean parameters as keyword-only
> parameters.
>

It is true for literal keywords arguments, but passing a named variable with
a boolean value can be fine.

    # Bad
    my_func(True)

    # Good
    my_func(enable=True)

    # Good
    enable=True
    my_func(enable)

    # Meh
    enable=True
    my_func(enable=enable)

    # Bad
    w=True
    my_func(w)

That list of examples seems to be aligned along the wrong axis.

--
--Guido van Rossum (python.org/~guido)