qazwsx qazwsx - 1 year ago 99
Python Question

Spaces in Python coding style

Python tutorial says "Use spaces around operators and after commas, but not directly inside bracketing constructs: a = f(1, 2) + g(3, 4)." What does "not directly inside bracketing constructs" exactly mean?

Answer Source

That probably comes from PEP 8 -- Style Guide for Python Code. Specifically, see the section on "Whitespace in Expressions and Statements."

From that section:

Avoid extraneous whitespace in the following situations:

- Immediately inside parentheses, brackets or braces.

  Yes: spam(ham[1], {eggs: 2})
  No:  spam( ham[ 1 ], { eggs: 2 } )
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download