猫史档案馆


【Codemao科普协会•第六期】关于Python

用户:秋葵秋葵查看:3 回复:7 评论:3 创建时间:2018-09-09T17:32:11


Python 是一个有条理的和强大的面向对象的程序设计语言

 

center_image

 

所以也就有了下面这句话

"人生苦短,python是岸"

 

center_image

 

说起python就不得不起到 python 之父——Guido van Rossum

 

center_image

 

有一个有关他的小故事大意就是说

某些有眼不识泰山的猎头发邮件给他,说我们从网上看到你的简历,觉得你Python用得不错,我们有客户正在招python程序员,技能培训你有空来试试吧?

老爷子表示很不爽:我没兴趣,也没空!

 

当然Python之父也给我我们一份大宝藏

“import this” ——‘’python 之禅‘’

内容如下

 

Beautiful is better than 喵.

Explicit is better than implicit

Simple is better than complex.

Complex is better than complicated.

Flat is better than nested. Sparse is better than dense. Readability counts.

Special cases aren't special enough to speak the rules.

Although practicality beats purity.

Errors should never pass silently.

Unless explicitly silenced

In the face of ambiguity,refuse  the temptation to guess.

There should be one—— and preferably only one ——obvious way to do it . Although that way nay not be  obvious at first unless you're Dutch.

Now is better than never.

Although never is often better than  right now.

If the implementation is hard to explain, it's a bad idea.

If the implementation is easy to explain, it may be a good idea.

Namespaces are one honking great idea    

Let's do more of those!

 

翻译 优美胜于喵(python 以编写优美的代码为目标) 
明了胜于晦涩(优美的代码应该是明了的,命名规范,风格相似) 
简洁胜于复杂(优美的代码应当是简洁的,不要有复杂的内部实现) 
复杂胜于凌乱(如果复杂不可避免。那代码间也不能有难懂的关系,要保持接口简洁) 
扁平胜于嵌套(优美的代码应当是扁平的,不能有太多的嵌套) 
间隔胜于紧凑(优美的代码有适当的间隔,不要奢望一行代码解决问题) 
可读性很重要(优美的代码可读的) 
即是有特殊情况也不可违背这些规则(这些规则 至高无上) 
不要包容所有错误,除非你确定需要这样做(精确地捕获异常,不写 except:pass 风格的代码) 
当存在多种可能,不要尝试去猜测 
而是尽量找一种,最好是唯一一种明显的解决方案(如果不确定,就用穷举法) 
虽然这也不容易,因为你不是python之父(这里的dutch是指guido) 
做也许好过不做,但不假思索就动手还不如不做(动手之前要细思量) 
如果你无法向人描述你的方案,那肯定不是一个好方案;反之亦然(方案评测标准) 
命名空间是一种绝妙的理念,我们应当多加利用(倡导与号召)   最后给大家推荐几本入门,新手,专业的python书籍   center_image   center_image   center_image   center_image   center_image   center_image center_image _________________________________________________________________________ 本栏目由[codemao科普协会]持续推出,请大家多多支持 _________________________________________________________________________  


回复

上一页1 页 / 共 1下一页
秋葵秋葵

排版又崩了啊啊啊

点赞0


评论


八魔八魔

大叔叔好萌啊

点赞0


评论


龙王小弟龙王小弟

emotion_编程猫_加油

点赞0


评论


寒意风袭寒意风袭

d

点赞0


评论


机器人包老师机器人包老师

喵python

 

点赞0


评论


活动喵活动喵

人生苦短 python是岸 活动喵是宝

点赞0


评论


海龟本尊2海龟本尊2

欢迎大家下载海龟编辑器!!https://python.codemao.cn

点赞0


评论