python中属性名称的最大长度是多少? [英] What is the maximum length for an attribute name in python?

查看:62
本文介绍了python中属性名称的最大长度是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一组 Python 函数,用于对源代码项目执行某种一致性检查.我想为这些函数指定相当冗长的名称,例如:check_5_theVersionOfAllVPropsMatchesTheVersionOfTheAutolinkHeader()

I'm writing a set of python functions that perform some sort of conformance checking on a source code project. I'd like to specify quite verbose names for these functions, e.g.: check_5_theVersionOfAllVPropsMatchesTheVersionOfTheAutolinkHeader()

这么长的名字会不会是python的问题?属性名称有最大长度吗?

Could such excessively long names be a problem for python? Is there a maximum length for attribute names?

推荐答案

2.3.标识符和关键字来自 Python 语言参考:

2.3. Identifiers and keywords from The Python Language Reference:

标识符的长度没有限制.

Identifiers are unlimited in length.

<小时>

但是你会违反PEP-8 很可能,这不是很酷:


But you'll be violating PEP-8 most likely, which is not really cool:

将所有行限制为最多 79 个字符.

Limit all lines to a maximum of 79 characters.

此外,您还将违反 PEP-20(禅宗蟒):

Also you'll be violating PEP-20 (the Zen of Python):

可读性很重要.

这篇关于python中属性名称的最大长度是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆