3

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?

1
  • 2
    There's examples in Pep8 Commented Mar 15, 2012 at 4:56

3 Answers 3

11

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 } )
Sign up to request clarification or add additional context in comments.

Comments

5

It means you shouldn't do things like a = f ( 1 ) or l = [ 2, 3 ].

Comments

5

I think it means do this:

x = (1, 2)

not this:

x = ( 1, 2 )

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.