表达式和参数列表中的空格 [英] white space in expressions and argument lists

查看:56
本文介绍了表达式和参数列表中的空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个小问题,但我很好奇是否有任何类型的最佳实践

在Python

世界中的表达式和参数列表中使用空格。例如:


1 + 2或1 + 2

func(1,2)或func(1,2)

对我而言,这个空间使它更好更易读,但我很惊讶

在Guido的博客中读到他认为1 + 2应该是正常的方式

写下来。其他人的想法是什么?

A minor concern, but I''m curious if there is any kind of best practice
for using whitespace within expressions and argument lists in the Python
world. For example:

1 + 2 or 1+2

func(1,2) or func(1, 2)

To me, the space makes it nicer and more readable, but I was surprised
to read in Guido''s blog that he thinks 1+2 should be the normal way to
write it. What does everyone else think?

推荐答案

John Salerno< jo ****** @ NOSPAMgmail.com>写道:
John Salerno <jo******@NOSPAMgmail.com> writes:
1 + 2或1 + 2

func(1,2)或func(1,2)
1 + 2 or 1+2

func(1,2) or func(1, 2)




我更喜欢并使用1 + 2和func(1,2)

我不会只在参数默认值中做空格,例如


func(foo = baz)


-

劳伦斯 - http://www.oluyede.org/blog

任何人都可以自由地使用他想要的任何东西,但最后的光线

他的大多数问题的隧道是Python"



I prefer and use 1 + 2 and func(1, 2)
I don''t do whitespaces only in argument defaults like

func(foo=baz)

--
Lawrence - http://www.oluyede.org/blog
"Anyone can freely use whatever he wants but the light at the end
of the tunnel for most of his problems is Python"


John Salerno写道:
John Salerno wrote:
一个小问题,但是我很好奇是否有任何类型的最佳实践
在Python
世界中的表达式和参数列表中使用空格。例如:

1 + 2或1 + 2
A minor concern, but I''m curious if there is any kind of best practice
for using whitespace within expressions and argument lists in the Python
world. For example:

1 + 2 or 1+2




IMO,好的风格要求空格。大多数公司都有

程序员可以遵循的风格指南。阅读本PEP:

http:// www.python.org/peps/pep-0008.html


John Salerno启发我们:
John Salerno enlightened us with:
对我来说,空间使它更好,更易读,但我很惊讶在Guido的博客中读到他认为1 + 2应该是写它的正常方式。其他人的想法是什么?
To me, the space makes it nicer and more readable, but I was
surprised to read in Guido''s blog that he thinks 1+2 should be the
normal way to write it. What does everyone else think?




我通常写1 + 2和func(a,b)。有时候我甚至会用更多的空间来对齐东西:


foo =''bar''

foobar = 42

azimov = 3

Sybren

-

世界的问题是愚蠢。并不是说应该对愚蠢的死刑进行处罚,但为什么我们不要仅仅拿掉

安全标签来解决问题呢? br />
Frank Zappa



I usually write 1 + 2 and func(a, b). Sometimes I even use more spaces
to align stuff:

foo = ''bar''
foobar = 42
azimov = 3

Sybren
--
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don''t we just take the
safety labels off of everything and let the problem solve itself?
Frank Zappa


这篇关于表达式和参数列表中的空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆