【发布时间】:2017-09-27 00:17:03
【问题描述】:
为什么 PyCharm 将嵌套代码块末尾的换行 cmets 折叠到前一个块中?
示例(尝试折叠第一个“if”块):
def print_me(a):
# newline comment
if a == 'me':
dummy_padding = ''
if not dummy_padding:
favorite_place = 'zoo'
print(a)
else:
pass
# invisible newline comment
elif a == 'you':
dummy_padding = ''
pass
# visible newline comment
elif a == 'us':
dummy_padding = ''
if not dummy_padding:
favorite_place = 'movies'
print(favorite_place)
# visible indented comment
elif a == 'them':
dummy_padding = ''
pass
return a
Python 中有没有规定函数内的 cmets 应该始终缩进的规范?如果没有,是否有某种方法可以调整 PyCharm 中的设置,使其在折叠嵌套代码时不会消失换行 cmets?
【问题讨论】:
标签: python pycharm code-folding