Unused argument warnings can be suppressed by deleting the variables at the beginning of the function. Always include a comment explaining why you are deleting it. “Unused.” is sufficient. For example: defviking_cafe_order(spam: str, beans: str, eggs: str|None=None)->str:delbeans, eggs#...
假设阅读代码的人比你更懂Python,他只是不知道你的代码要做什么。 # BAD COMMENT: Now go through the b array and make sure whenever i occurs # the next element is i+1 类 如果一个类不继承自其它类,就显式的从object继承,嵌套类也一样。 classSampleClass(object): pass classOuterClass(object): ...
(4)__double_leading_and_trailing_underscore__:前后使用双下划线,用于命名空间中的魔法(“magic”)对象和属性。例如:__init__, __import__ or __file__,永远不要发明这样的名字;只在文档中使用它们。 不要使用“l”,“O”,“i”等作为单个字符变量的名字,因为有时它们无法与数字“1”和“0”区分。 ...
foo = 1000 # comment long_name = 2 # comment that should not be aligned dictionary = { 'foo' : 1, 'long_name': 2, } 3.7 Shebang 大部分.py文件不需要从#!行来开始.根据PEP-394,程序的主文件应该以#!/usr/bin/python2或#!/usr/bin/python3起始 ...
关于Python代码的书写格式,有专门的文档在介绍,比如PEP 8 - Style Guide for Python Code。有兴趣可以看看,我这一线网工非开发人员,并没研究过它。 4.2 注释(comment) 代码除了写给编译器去看去执行,也是写给以后的自己看,写给工作的小伙伴们看。因此,我们在密密麻麻的代码中,非常有必要在适当位置加入一些注释。
# BAD COMMENT: Now go through the b array and make sure whenever i occurs# the next element is i+1 类 如果一个类不继承自其它类, 就显式的从object继承. 嵌套类也一样. Yes:classSampleClass(object):passclassOuterClass(object):classInnerClass(object):passclassChildClass(ParentClass):"""Expli...
style guide for python Comments Inline Comments Use inline comments sparingly. An inline comment is a comment on the same line as a statement. Inline comments should be separated by at least two spaces from the statement. T...猜你喜欢几个简单代码片段-- Google C++ style guide 欧洲杯,德国...
self.user_name =''self.Gender ='male'#comment in wrong identself.active =Falsedeflogin(self, Person): self.user_name=Person.user_name not_used_var =0returnTruedefLogout(self): self.active =Falsedefplace_order(self): place_order()defaction(): ...
这是一位大佬翻译的GooglePython代码风格指南,很全面。可以作为公司的code review 标准,也可以作为自己编写代码的风格指南。希望对你有帮助。 Translator: shendeguize@github Link: https://github.com/shendeguize/GooglePythonStyleGuideCN 本翻译囿于水平,可能有不准确的地方,欢迎指出,谢谢大家 ...
Unused argument warnings can be suppressed by deleting the variables at the beginning of the function. Always include a comment explaining why you are deleting it. “Unused.” is sufficient. For example: defviking_cafe_order(spam: str, beans: str, eggs: str|None=None)->str:delbeans, eggs...