我使用pycodestyle来检查代码样式,但我在这段代码中意识到:
# -*- coding: utf-8 -*-
class Button:
def __init__(self, foo, bar, text="empty"):
print foo
print bar
print text
# Not valid
button = Button(1, 2,
text="Player 1")
# Valid
buttons = [Button(6, 7,
text="Player 2")]
在PEP8 about indentation中说理想是这样的:
button = Button(foo, bar,
text="Player 1")
或者:
button = Button(
1, 2,
text="Player 1")
但我不明白为什么这是有效的:
buttons = [Button(6, 7,
text="Player 2")]
是因为数据结构还是 pycodestyle 错误?