Python - 命名规范

Python命名规范详解
本文详细介绍了Python之父Guido推荐的命名规范,包括模块名、包名、类名等各类标识符的命名方式,帮助开发者遵循一致的代码风格。

Python之父Guido推荐的命名规范包括如下几点:

  1. 模块名和包名采用小写字母并且以下划线分隔单词的形式;
  2. 类名采用以大写字母开头,并且以大写字母分隔单词的形式命名;
  3. 全局或者类常量,全部使用大写字母,并且以下划线分隔单词;其余变量命名则是采用全部小写字母,并且以下划线分隔单词的形式命名。
  4. 以上的内容如果是内部的,则使用下划线开头命名。
TypePublicInternal
Moduleslower_with_under_lower_with_under
Packageslower_with_under
ClassesCapWords_CapWords
ExceptionsCapWords
Functionslower_with_under()_lower_with_under()
Global/Class ConstantsCAPS_WITH_UNDER_CAPS_WITH_UNDER
Global/Class Variableslower_with_under_lower_with_under
Instance Variableslower_with_under_lower_with_under (protected) or __lower_with_under (private)
Method Nameslower_with_under()_lower_with_under() (protected) or __lower_with_under() (private)
Function/Method Parameterslower_with_under
Local Variableslower_with_under

转自: http://www.gcsjj.cn/articles/2019/04/20/1555742075731.html

转载于:https://my.oschina.net/cttmayi/blog/824876

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值