Python支持用于定义代码块的大括号,并且它还支持使用“开始”和“结束”标记。
请看这些代码示例:class MyClass(object): #{
def myfunction(self, arg1, arg2): #{
for i in range(arg1): #{
print i
#}
#}
#}
还有一个带有bash样式的例子:fi = endclass = enddef = endclass = done = None
class MyClass(object):
def myfunction(self, arg1, arg2):
for i in range(arg1): #do
if i > 5: #then
print i
fi
done
enddef
endclass
这方面最好的一点是,你可以忘记在其中放置一个近距括号,而它仍然是有效的python!class MyClass(object): #{
def myfunction(self, arg1, arg2): #{
for i in range(arg1): #{
print i
# whoops, forgot to close that bracket!
#}
#}