[Python-Dev] Suggested addition to PEP 8 for context managers (original) (raw)
Steven D'Aprano steve at pearwood.info
Thu Apr 19 02:16:05 CEST 2012
- Previous message: [Python-Dev] Suggested addition to PEP 8 for context managers
- Next message: [Python-Dev] cpython: Update importlib.h
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hrvoje Niksic wrote:
The same oddity occurs with expressions in kwargs calls:
func(pos1, pos2, keyword=foo + bar) I find myself wanting to add parentheses arround the + to make the code clearer.
Then why don't you?
In the above example, spaces around the + are not only optional but discouraged, this would be preferred:
func(pos1, pos2, keyword=foo+bar)
but if you insist on using spaces (perhaps because it is part of a larger expression) just use parentheses.
func(pos1, pos2, keyword=(foospamham*eggs + bar/spam**cheese))
Strictly speaking they're not needed, but if they make it easier to read (and I think they do) then why would you not use them?
-- Steven
- Previous message: [Python-Dev] Suggested addition to PEP 8 for context managers
- Next message: [Python-Dev] cpython: Update importlib.h
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]