pyzh / song

[又]一个硬核FP论坛;索引->type=source
https://github.com/program-in-chinese/overview/issues/68
9 stars 1 forks source link

Ld2:Python变量命名规范 #26

Open 4b5ent1 opened 5 years ago

4b5ent1 commented 5 years ago

Ld2/py3/pep-1,简称LEP-1

c1. 类前缀:interface用大写I,节点/集合用大写N,abstract用大写A c2. 类后缀:helper类/可选后缀H

c3. 实体类:可选前缀=E,后缀=

identifier/变量名:

i1. 用[此]代替[this] i2. 无实义变量以字母v开头,如v1 v2 v3;常量以c开头 i3. 无实义函数以字母f开头;单目函数可用f1/fx,双目用f2/g,三目用f3/h/z i4. 无实义参数中:参数间无顺序/可用XYZ,A/B可以表示左参数/右参数 i5. 业务逻辑函数/class method一律优先使用中文 i6. n,i/j/k表示数值参数,L,li表示List,t表示tuple,D/dic=dict,S->str->string i7. 可以用[参]替代[argv],[参数]替代[args]

单字母规范补充:

a1. T=Type a2. F=file /函数用小写f或fn替代 a3. C~=class /建议用cls替代 a4. b,~bin/bit;e,~element;g,~global;h,~head[t~tail] /~handle; a5. N~number;o,~obj/对象/object;p,~ptr/指针/pointer;q~(ref:静态工作点 a6. 避免使用大写字母U / 为了和并集符号区分开来 a7. w~word;a/z~第一个/最后一个

其他常用缩写:

c> cls;r> ref;

// 其他想到再补充

todo:注释规范

# 注释一律优先使用中文
#>
##
###
####
#:
#=
#==
#=#
#?
#^
#~
#>>
#+
#1 
#`
#_#
#*
# //
#[1个空格]
#[2/3/4个空格]
4b5ent1 commented 5 years ago

ref: github.com> https://github.com/program-in-chinese/overview/issues/91 《关于简化关键词汉化的一些建议 https://github.com/program-in-chinese/overview/issues/40#issuecomment-426583945 《中文化 类C编程语言 需要什么样的关键字?