Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ld2:Python变量命名规范 #26

Open
4b5ent1 opened this issue Oct 13, 2018 · 1 comment
Open

Ld2:Python变量命名规范 #26

4b5ent1 opened this issue Oct 13, 2018 · 1 comment
Labels
中文编程 program in chinese

Comments

@4b5ent1
Copy link

4b5ent1 commented Oct 13, 2018

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
Copy link
Author

4b5ent1 commented Oct 13, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
中文编程 program in chinese
Projects
None yet
Development

No branches or pull requests

2 participants