A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2012-April/118873.html below:

[Python-Dev] Suggested addition to PEP 8 for context managers

[Python-Dev] Suggested addition to PEP 8 for context managers [Python-Dev] Suggested addition to PEP 8 for context managersSteven D'Aprano steve at pearwood.info
Thu Apr 19 02:16:05 CEST 2012
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=(foo*spam*ham*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
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4