PEP 8, why no spaces around '=' in keyword argument or a default parameter value?

后端 未结 6 1744
天涯浪人
天涯浪人 2021-01-30 09:54

Why does PEP 8 recommend not having spaces around = in a keyword argument or a default parameter value?

Is this inconsistent with recommending spaces around every other

6条回答
  •  再見小時候
    2021-01-30 10:24

    There are pros and cons.

    I very much dislike how PEP8 compliant code reads. I don't buy into the argument that very_long_variable_name=another_very_long_variable_name can ever be more human readable than very_long_variable_name = another_very_long_variable_name. This is not how people read. It's an additional cognitive load, particularly in the absence of syntax highlighting.

    There is a significant benefit, however. If the spacing rules are adhered to, it makes searching for parameters exclusively using tools much more effective.

提交回复
热议问题