|
| 1 | +--- |
| 2 | +title: The must-read Python's PEPs |
| 3 | +categories: |
| 4 | +- howto |
| 5 | +- english |
| 6 | +tags: |
| 7 | +- python |
| 8 | +- PEP |
| 9 | +--- |
| 10 | + |
| 11 | +As Python developer, you should know what a PEP is. In case you don't, |
| 12 | +> "PEP |
| 13 | +stands for **Python Enhancement Proposal**. A PEP is a design document |
| 14 | +providing information to the Python community, or describing a new feature for |
| 15 | +Python or its processes or environment. The PEP should provide a concise |
| 16 | +technical specification of the feature and a rationale for the feature" |
| 17 | +(from [PEP 1](https://www.python.org/dev/peps/pep-0001/)) |
| 18 | + |
| 19 | +There are three kinds of PEP: |
| 20 | +- A **Standards Track PEP** describes a new feature or implementation for |
| 21 | +Python |
| 22 | +- An **Informational PEP** describes a Python design issue, or provides general |
| 23 | +guidelines or information to the Python community, but does not propose a new |
| 24 | +feature |
| 25 | +- A **Process PEP** describes a process surrounding Python, or proposes a |
| 26 | +change to (or an event in) a process. Process PEPs are like Standards Track |
| 27 | +PEPs but apply to areas other than the Python language itself |
| 28 | + |
| 29 | +All PEPs are stored in a [github repository](https://github.com/python/peps) |
| 30 | +and the list is in the [PEP 0](https://www.python.org/dev/peps/) |
| 31 | + |
| 32 | +Now, the main question is: "**What are the most important PEPs that a Python |
| 33 | +developer should be aware of?**" I went through the long list and I chose the |
| 34 | +ones that I think are important to know. |
| 35 | + |
| 36 | +The must know PEPs without witch you cannot be considered a Python programmer |
| 37 | +are: |
| 38 | +- [PEP 20 -- The Zen of Python](https://www.python.org/dev/peps/pep-0020/): |
| 39 | +that's the first PEP you need to read and apply throughout your Python |
| 40 | +development |
| 41 | +- [PEP 8 -- Style Guide for Python Code](https://www.python.org/dev/peps/ |
| 42 | +pep-0008/): this PEP defines the coding convention when writing Python. |
| 43 | +I expect everyone writing PEP8 compliant code |
| 44 | +- [PEP 257 -- Docstring Conventions](https://www.python.org/dev/peps/ |
| 45 | +pep-0257/): conventions for Docstring in Python |
| 46 | +- [PEP 287 -- reStructuredText Docstring Format](https://www.python.org/dev/ |
| 47 | +peps/pep-0257/): when plain text is not enough, reStructuredText is the answer |
| 48 | +for Docstring |
| 49 | + |
| 50 | +The following PEPs don't fall into any category but it's good to know their |
| 51 | +existence anyway: |
| 52 | +- [PEP 7 -- Style Guide for C Code](https://www.python.org/dev/peps/pep-0007/): |
| 53 | +if you need to contribute to C implementation of Python, that's the PEP for |
| 54 | +you |
| 55 | +- [PEP 404 -- Python 2.8 Un-release Schedule](https://www.python.org/dev/peps/ |
| 56 | +pep-0404/): release not found! There will be never a 2.8 Python release. |
| 57 | +The last Python 2 release is 2.7. It's time to move to Python 3! |
| 58 | +- [PEP 440 -- Version Identification and Dependency Specification](https://www. |
| 59 | +python.org/dev/peps/pep-0440/): this PEP describes a scheme for identifying |
| 60 | +versions of Python software distributions, and declaring dependencies on |
| 61 | +particular versions |
| 62 | + |
| 63 | +The following PEPs instead will be split between Python versions (2 and 3) and |
| 64 | +they just represent an attempt to summarise the most relevant ones in order to |
| 65 | +pick peculiarities of the language itself. The version of python affected and |
| 66 | +some personal extra comments will be side noted. |
| 67 | + |
| 68 | +## Python 2 |
| 69 | +- [PEP 201 -- Lockstep Iteration (zip function)](https://www.python.org/dev/ |
| 70 | +peps/pep-0201/) (2.0) - _it's very handy_ |
| 71 | +- [PEP 202 -- List Comprehensions](https://www.python.org/dev/peps/pep-0202/) |
| 72 | +(2.0) - _one of my favourites_ |
| 73 | +- [PEP 221 -- Import As](https://www.python.org/dev/peps/pep-0221/) (2.0) |
| 74 | +- [PEP 234 -- Iterators](https://www.python.org/dev/peps/pep-0234/) (2.1) - |
| 75 | +_trust me, you will use them_ |
| 76 | +- [PEP 236 -- Back to the \_\_future\_\_](https://www.python.org/dev/peps/ |
| 77 | +pep-0236/) (2.1) - _do you want to use_ `print()` _(from Python 3.X) in Python |
| 78 | +2.X? That's the module for you_ |
| 79 | +- [PEP 255 -- Simple Generators (yield)](https://www.python.org/dev/peps/ |
| 80 | +pep-0255/) (2.2) - _once you know it, you'll love it_ |
| 81 | +- [PEP 279 -- The enumerate() built-in function](https://www.python.org/dev/ |
| 82 | +peps/pep-0279/) (2.3) - _sometime it is very useful_ |
| 83 | +- [PEP 282 -- A Logging System](https://www.python.org/dev/peps/pep-0282/) |
| 84 | +(2.3) - _please, don't debug with_ `print()` |
| 85 | +- [PEP 285 -- Adding a bool type](https://www.python.org/dev/peps/pep-0285/) |
| 86 | +(2.3) - _I don't understand how you live without it!_ |
| 87 | +- [PEP 289 -- Generator Expressions](https://www.python.org/dev/peps/pep-0289/) |
| 88 | +(2.4) - _list comprehensions with generators_ |
| 89 | +- [PEP 308 -- Conditional Expressions](https://www.python.org/dev/peps/ |
| 90 | +pep-0308/) (2.4) - _Python "ternary" expression:_ `X if C else Y` |
| 91 | +- [PEP 318 -- Decorators for Functions and Methods](https://www.python.org/dev/ |
| 92 | +peps/pep-0318/) (2.4) - _@decorators are methods which wrap functions and |
| 93 | +methods_ |
| 94 | +- [PEP 322 -- Reverse Iteration](https://www.python.org/dev/peps/pep-0322/) |
| 95 | +(2.4) |
| 96 | +- [PEP 324 -- subprocess - New process module](https://www.python.org/dev/peps/ |
| 97 | +pep-0324/) (2.4) |
| 98 | +- [PEP 327 -- Decimal Data Type](https://www.python.org/dev/peps/pep-0327/) |
| 99 | +(2.4) - _floatintg point are just too inexact. Period._ |
| 100 | +- [PEP 341 -- Unifying try-except and try-finally](https://www.python.org/dev/ |
| 101 | +peps/pep-0341/) - _Do you know that_ `try` _constructs allow an_ `else` |
| 102 | +_statement?_ |
| 103 | +- [PEP 342 -- Coroutines via Enhanced Generators](https://www.python.org/dev/ |
| 104 | +peps/pep-0342/) (2.5) - _still need to get those!_ |
| 105 | +- [PEP 343 -- The "with" Statement](https://www.python.org/dev/peps/ |
| 106 | +pep-0343/) (2.5) - _really? Don't you know it? Shame on you!_ |
| 107 | +- [PEP 367 -- New Super](https://www.python.org/dev/peps/pep-0367/) (2.6) - |
| 108 | +_that's important, read it!_ |
| 109 | + |
| 110 | +## Python 2 and 3 |
| 111 | +- [PEP 274 -- Dict Comprehensions](https://www.python.org/dev/peps/pep-0274/) |
| 112 | +(originally 2.3, then 2.7 and 3.0) - _the beauty of list comprehensions applied |
| 113 | +to_ `Dict` |
| 114 | +- [PEP 372 -- Adding an ordered dictionary to collections](https:// |
| 115 | +www.python.org/dev/peps/pep-0372/) (2.7, 3.1) - _because order matters_ |
| 116 | +- [PEP 389 -- argparse - New Command Line Parsing Module](https:// |
| 117 | +www.python.org/dev/peps/pep-0389/) (2.7, 3.2) - _please, stop using optparse |
| 118 | +right now!_ |
| 119 | + |
| 120 | +## Python 3 |
| 121 | +- [PEP 380 -- Syntax for Delegating to a Subgenerator (yield from)]( |
| 122 | +https://www.python.org/dev/peps/pep-0380/) (3.3) - _a generator to delegate |
| 123 | +part of its operations to another generator_ |
| 124 | +- [PEP 405 -- Python Virtual Environments](https://www.python.org/dev/peps/ |
| 125 | +pep-0405/) (3.3) - _I'm really glad to see a tighter integration with virtual |
| 126 | +environments_ |
| 127 | +- [PEP 417 -- Including mock in the Standard Library](https://www.python.org/ |
| 128 | +dev/peps/pep-0417/) (3.3) - _it's one of the first modules I pip install when |
| 129 | +using Python 2.7_ |
| 130 | +- [PEP 435 -- Adding an Enum type to the Python standard library]( |
| 131 | +https://www.python.org/dev/peps/pep-0435/) (3.4) |
| 132 | +- [PEP 450 -- Adding A Statistics Module To The Standard Library]( |
| 133 | +https://www.python.org/dev/peps/pep-0450/) (3.4) - _never used so far, but I |
| 134 | +recognise its importance_ |
| 135 | +- [PEP 483 - The Theory of Type Hints](https://www.python.org/dev/peps/ |
| 136 | +pep-0483/) (3.5) - _that's just a theory for the next PEP_ |
| 137 | +- [PEP 484 - Type Hints ](https://www.python.org/dev/peps/pep-0484/) (3.5) - |
| 138 | +_they are used to easier static analysis and refactoring, potential runtime |
| 139 | +type checking, and (perhaps, in some contexts) code generation utilizing type |
| 140 | +information. **Python will remain a dynamically typed language, and the authors |
| 141 | +have no desire to ever make type hints mandatory, even by convention**_ |
| 142 | +- [PEP 485 -- A Function for testing approximate equality]( |
| 143 | +https://www.python.org/dev/peps/pep-0485/) (3.5) - `is_close` _enough_ :) |
| 144 | +- [PEP 492 -- Coroutines with async and await syntax]( |
| 145 | +https://www.python.org/dev/peps/pep-0492/) (3.5) - _coroutines start being a |
| 146 | +proper concept in Python_ |
| 147 | +- [PEP 525 -- Asynchronous Generators](https://www.python.org/dev/peps/ |
| 148 | +pep-0525/) (3.6) - _generators made asynchronous_ |
| 149 | +- [PEP 526 -- Syntax for Variable Annotations](https://www.python.org/dev/ |
| 150 | +peps/pep-0526/) (3.6) - _it's like PEP 484 but for variables_ |
| 151 | +- [PEP 530 -- Asynchronous Comprehensions](https://www.python.org/dev/peps/ |
| 152 | +pep-0530/) (3.6) - _things are getting complicated eh... asynchronous versions |
| 153 | +of list, set, dict comprehensions and generator expressions_ |
| 154 | +- [PEP 3000 -- Python 3000](https://www.python.org/dev/peps/pep-3000/) (3000) - |
| 155 | +_where 3v3rything begins!_ |
| 156 | +- [PEP 3101 -- Advanced String Formatting](https://www.python.org/dev/peps/ |
| 157 | +pep-3101/) (3.0) - _stop using % for string formatting and embrace_ `.format()` |
| 158 | +_method (included in Python 2.6 as well)_ |
| 159 | +- [PEP 3105 -- Make print a function](https://www.python.org/dev/peps/ |
| 160 | +pep-3105/) (3.0) - _I told you not to use_ `print` _for debugging! Now all your |
| 161 | +Python 2.X needs a huge refactoring for working in Python 3.X. Joking apart, |
| 162 | +that's the most common error when you try to run Python 2.X code using Python |
| 163 | +3.X intepreter._ |
| 164 | +- [PEP 3107 -- Function Annotations](https://www.python.org/dev/peps/pep-3107/) |
| 165 | +(3.0) |
| 166 | +- [PEP 3109 -- Raising Exceptions in Python 3000](https://www.python.org/dev/ |
| 167 | +peps/pep-3109/) (3.0) - _yep, in Python 3.X,_ `raise` _changes a bit. It's worth |
| 168 | +having a look_ |
| 169 | +- [PEP 3110 -- Catching Exceptions in Python 3000](https://www.python.org/dev/ |
| 170 | +peps/pep-3110/) (3.0) - _see above_ |
| 171 | +- [PEP 3115 -- Metaclasses in Python 3000](https://www.python.org/dev/peps/ |
| 172 | +pep-3115/) (3.0) - _well, if you have ever used_ `__metaclass__`_, Python 3.X |
| 173 | +don't_ |
| 174 | +- [PEP 3119 -- Introducing Abstract Base Classes](https://www.python.org/dev/ |
| 175 | +peps/pep-3119/) (3000) - `abc`_, no I haven't forgotten the alphabet :)_ |
| 176 | +- [PEP 3120 -- Using UTF-8 as the default source encoding]( |
| 177 | +https://www.python.org/dev/peps/pep-3120/) (3.0) - _this PEP removes a lot of |
| 178 | +headeaches we have in Python 2.X_ |
| 179 | +- [PEP 3129 -- Class Decorators](https://www.python.org/dev/peps/pep-3129/) |
| 180 | +(3.0) - _like PEP 318 but for classes_ |
| 181 | +- [PEP 3135 -- New Super](https://www.python.org/dev/peps/pep-3135/) (3.0) - |
| 182 | +_it's PEP 367 for Python 3.X_ |
| 183 | +- [PEP 3148 -- futures - execute computations asynchronously]( |
| 184 | +https://www.python.org/dev/peps/pep-3148/) (3.2) - _The_ `concurrent.futures` |
| 185 | +_module provides a high-level interface for asynchronously executing callables_ |
| 186 | +- [PEP 3156 -- Asynchronous IO Support Rebooted: the "asyncio" Module]( |
| 187 | +https://www.python.org/dev/peps/pep-3156/) (3.3) - _this is it! the asyncio |
| 188 | +module_ |
| 189 | + |
| 190 | +Have I missed anything? What's your favourite PEP? |
0 commit comments