Code Style Guide - activesys/alpaca-llama GitHub Wiki

alpaca-llama Python Code Style Guide

参考下面编码规范:

  1. PEP8 Style Guide for Python Code
  2. Google Python Style Guide

与上述规范不同:

  • 不限制单行最大长度,建议单行最大长度保持在120,大块文本(文档或者注释)的长度保持在110。
  • 带有一行语句的if/for/while也不要放在一行上,除了使用pass:

Yes:

if foo == 'blah':
    do_something()

for x in lst:
    total += x

while t < 10:
    t = delay()

while t < 10: pass

No:

if foo == 'blah': do_something()
for x in lst: total += x
while t < 10: t = delay()
while t < 10:
    pass
  • 对于version bookkeeping不做强制性要求,建议不使用。