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

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.

主站蜘蛛池模板: 台州市| 珲春市| 林口县| 丽江市| 永川市| 禹州市| 阿克陶县| 固原市| 九龙城区| 澜沧| 德州市| 顺平县| 信丰县| 博乐市| 商南县| 剑阁县| 中牟县| 青田县| 班玛县| 阜宁县| 徐水县| 静安区| 石棉县| 图木舒克市| 恩施市| 芮城县| 南丰县| 临邑县| 万源市| 德钦县| 平山县| 新郑市| 英德市| 东阿县| 铜山县| 建阳市| 德庆县| 密山市| 镇沅| 布尔津县| 尉犁县|