- Expert Python Programming(Second Edition)
- Micha? Jaworski Tarek Ziadé
- 258字
- 2021-07-16 10:58:06
Chapter 2. Syntax Best Practices – below the Class Level
The ability to write an efficient syntax comes naturally with time. If you take a look back at your first program, you will probably agree with this. The right syntax will appear to your eyes as a good-looking piece of code, and the wrong syntax as something disturbing.
Besides the algorithms that are implemented and the architectural design for your program, taking great care over how it is written weighs heavily on how it will evolve. Many programs are ditched and rewritten from scratch because of their obtuse syntax, unclear APIs, or unconventional standards.
But Python has evolved a lot in the last few years. So, if you were kidnapped for a while by your neighbor (a jealous guy from the local Ruby developers user group) and kept away from the news, you will probably be astonished by its new features. From the earliest version to the current one (3.5 at this time), a lot of enhancements have been made to make the language clearer, cleaner, and easier to write. Python basics have not changed drastically, but the tools to play with them are now a lot more ergonomic.
This chapter presents the most important elements of modern syntax and tips on their usage:
- List comprehensions
- Iterators and generators
- Descriptors and properties
- Decorators
with
andcontextlib
The code performance tips for speed improvement or memory usage are covered in Chapter 11, Optimization – General Principles and Profiling Techniques, and Chapter 12, Optimization – Some Powerful Techniques.
- The DevOps 2.3 Toolkit
- 華為HMS生態與應用開發實戰
- 機械工程師Python編程:入門、實戰與進階
- Apache Mesos Essentials
- Java應用開發技術實例教程
- Visual FoxPro程序設計
- Expert Data Visualization
- 硅谷Python工程師面試指南:數據結構、算法與系統設計
- Java EE核心技術與應用
- 領域驅動設計:軟件核心復雜性應對之道(修訂版)
- Unity 2017 Mobile Game Development
- 持續集成與持續交付實戰:用Jenkins、Travis CI和CircleCI構建和發布大規模高質量軟件
- 微課學人工智能Python編程
- Learning Ionic
- Data Science Algorithms in a Week