Python----Python之禅(Python的禅)

网友投稿 390 2022-08-23


Python----Python之禅(Python的禅)

1、import this 开启Python之禅

>>> import thisThe Zen of Python, by Tim PetersBeautiful is better than ugly.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 break 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 may 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!>>>

2、Python之禅(中文)

优美胜于丑陋,明了胜于晦涩。简洁胜于复杂,复杂胜于凌乱。扁平胜于嵌套,稀疏胜于密繁。可读性很重要!即便假借特例的实用性之名,也不可违背这些规则。不要放过一切错误,除非错误本身需要以忽略对待。不确定面前,我们应抵挡妄加猜测的引诱。应该有一种,也但愿只有这一种是显而易见的解决之道。万事开头难,除非荷兰人。做好过不做,而不假思索就动手还不如不做。如果某个实现无法很好阐释,那么它肯定是一个糟糕的办法;如果某个实现很容易说清楚,那么它可能就是个不错的方案。命名空间是个绝妙的发明——对此我们应多多益善!


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Java集合框架之Map详解
下一篇:Python----pathlib模块的用法
相关文章

 发表评论

暂时没有评论,来抢沙发吧~