各位企业项目开发中代码的注释需要写英文注释吗?
有些公司因为内码问题,在编码规范中强制规定部分语言的注释只允许用英文。
但是好像大部分日常写代码时 我们用的还是中文注释。
我现在想满满养成英文注释的习惯,但是不知道以后在公司中该准售怎样的一个准则。
比如:
- 参数注释需要英文吗?
- 方法的注释需要使用英文吗?
- 打印日志需要用英文吗?
- 代码中的print可以打印英文吗?如果需要用中文,是否可以将参数用英文?
- 等等,或者各位的大佬们在其他地方还有以下注意的事项,也可以告诉我一哈~
我的注释:
(部分代码)
class Bayes():
def __init__(self,
absPath:dict(type = str, help="Directory of the current file") = os.path.dirname(os.path.abspath(__file__)),
):
self.absPath = absPath
#contain all documents and list without duplicate words
def createVocabList(self,
dataSet:dict(type="", help = "the source data"),
)->dict(type=list, help = "Deduplicated list"):
vocabSet=set([]) #creat an empty set,'set' is a list without duplicate words
for document in dataSet:
vocabSet=vocabSet|set(document) #create an union of two sets
return list(vocabSet)
#determine if a term appears in the documents
def setOfWords2Vec(self,
vocabList = dict(type="", help="a glossary "),
inputSet = dict(type="", help="The word you want to detect"),
)->dict(type="", help="Word vector"):
returnVec = [0]*len(vocabList)
for word in inputSet:
if word in vocabList:
returnVec[vocabList.index(word)] = 1
else:
print("单词: %s 不在我的词汇里面!" % word)#Returns a document vector indicating whether a word has appeared 1/0 in the input document
return returnVec
文章!!首发于我的博客Stray_Camel(^U^)ノ~YO。
注释
PEP 8 程序代码的编写风格指南