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

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.

主站蜘蛛池模板: 杭锦后旗| 交口县| 施甸县| 古蔺县| 麦盖提县| 青冈县| 开封县| 景德镇市| 柳州市| 驻马店市| 菏泽市| 彰武县| 博野县| 泽库县| 宜宾市| 增城市| 伊金霍洛旗| 雷州市| 三明市| 油尖旺区| 天镇县| 长顺县| 敖汉旗| 溆浦县| 芮城县| 东方市| 平山县| 郑州市| 凭祥市| 博湖县| 浮梁县| 珠海市| 安丘市| 甘德县| 伊金霍洛旗| 留坝县| 应用必备| 应城市| 鹤峰县| 东莞市| 昌都县|