Python编码风格的空间 [英] Spaces in Python coding style
本文介绍了Python编码风格的空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从这一部分:
在以下情况下避免无关的空格:
- 立即在括号,括号或大括号内。
$ b是垃圾邮件(ham [1],{eggs:2})
否:垃圾邮件(ham [1],{eggs:2})
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?
解决方案
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 } )
这篇关于Python编码风格的空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文