官术网_书友最值得收藏!

Summary

This chapter showed us what the Pythonic philosophy is all about and explained to us what the Zen of Python is all about. While code style is highly personal, Python has a few, very helpful guidelines that at least keep people mostly on the same page and style. In the end, we are all consenting adults; everyone has the right to write code as he/she sees fit. But I do request you. Please read through the style guides and try to adhere to them unless you have a really good reason not to.

With all that power comes great responsibility, and so do a few pitfalls, though there aren't too many. Some are tricky enough to fool me regularly and I've been writing Python for a long time! Python improves all the time though. Many pitfalls have been taken care of since Python 2, but some will always remain. For example, recursive imports and definitions can easily bite you in most languages that support them, but that doesn't mean we'll stop trying to improve Python.

A good example of the improvements in Python over the years is the collections module. It contains many useful collections that have been added by users because there was a need. Most of them are actually implemented in pure Python, and because of that, they are easy enough to be read by anyone. Understanding might take a bit more effort, but I truly believe that if you make it to the end of this book, you will have no problem understanding what the collections do. Fully understanding how the internals work is something I cannot promise though; some parts of that go more towards generic computer science than Python mastery.

The next chapter will show you some of the collections available in Python and how they are constructed internally. Even though you are undoubtedly familiar with collections such as lists and dictionaries, you might not be aware of the performance characteristics involved with some of the operations. If some of the examples in this chapter were less than clear, you don't have to worry. The next chapter will at least revisit some of them, and more will come in later chapters.

主站蜘蛛池模板: 始兴县| 洪江市| 页游| 永德县| 泸定县| 泰州市| 诏安县| 大港区| 井研县| 通河县| 和静县| 班玛县| 临沂市| 达孜县| 锡林浩特市| 隆德县| 黑河市| 边坝县| 哈巴河县| 新邵县| 务川| 南康市| 库车县| 隆德县| 庄浪县| 石嘴山市| 边坝县| 黑山县| 日照市| 邵阳县| 鸡西市| 辽阳市| 航空| 宜兰市| 湛江市| 邹平县| 从化市| 望谟县| 南华县| 峨山| 仁寿县|