2024-10-03 06:27:57 发布
网友
我理解我们遵循自己的命名惯例的想法,但这完全是这样吗?例如,函数/变量名不能以数字开头,但可以包含“特殊”字符,对吗?但是:
@methodtrace(utils.logger)
给我提问题。@和.是否显著?我读过What is the naming convention in Python for variable and function names?
@
.
这不是编码样式(Python的样式是在PEP-8中定义的),而是语法的问题。你发布的不是一个名字。意思是:
^ decorate the following function ^ with the result of calling the function methodtrace ^ with a single argument, the logger attribute of utils
有效的Python标识符是在the documentation中定义的,它必须以字母(大写或小写)开头,然后包含零个或多个字母或数字。@是修饰函数的语法糖(参见What does the "at" (@) symbol do in Python?),括号是调用函数/方法的语法,.用于访问对象的属性。你知道吗
这不是编码样式(Python的样式是在PEP-8中定义的),而是语法的问题。你发布的不是一个名字。意思是:
有效的Python标识符是在the documentation中定义的,它必须以字母(大写或小写)开头,然后包含零个或多个字母或数字。
@
是修饰函数的语法糖(参见What does the "at" (@) symbol do in Python?),括号是调用函数/方法的语法,.
用于访问对象的属性。你知道吗相关问题 更多 >
编程相关推荐