๐”– Scriptorium
โœฆ   LIBER   โœฆ

๐Ÿ“

Clean Code in Python: Develop maintainable and efficient code, 2nd Edition

โœ Scribed by Mariano Anaya


Year
0
Tongue
English
Leaves
504
Category
Library

โฌ‡  Acquire This Volume

No coin nor oath required. For personal study only.

โœฆ Table of Contents


Preface......Page 16
Who this book is for?......Page 17
What this book covers......Page 19
Download the color images......Page 21
Conventions used......Page 22
Reviews......Page 23
Introduction, Code Formatting, and Tools......Page 25
The meaning of clean code......Page 26
The importance of having clean code......Page 27
Some exceptions......Page 29
Code formatting......Page 31
Adhering to a coding style guide on your project......Page 32
Documentation......Page 35
Code comments......Page 36
Docstrings......Page 37
Annotations......Page 41
Do annotations replace docstrings?......Page 45
Tooling......Page 47
Checking type consistency......Page 48
Generic validations in code......Page 51
Automatic formatting......Page 53
Setup for automatic checks......Page 56
Summary......Page 58
References......Page 59
Pythonic Code......Page 60
Indexes and slices......Page 61
Creating your own sequences......Page 63
Context managers......Page 66
Implementing context managers......Page 69
Comprehensions and assignment expressions......Page 73
Properties, attributes, and different types of methods for objects......Page 76
Underscores in Python......Page 77
Properties......Page 80
Creating classes with a more compact syntax......Page 83
Iterable objects......Page 87
Creating iterable objects......Page 88
Creating sequences......Page 91
Container objects......Page 93
Dynamic attributes for objects......Page 95
Callable objects......Page 98
Summary of magic methods......Page 99
Caveats in Python......Page 101
Mutable default arguments......Page 102
Extending built-in types......Page 103
A brief introduction to asynchronous code......Page 106
References......Page 109
General Traits of Good Code......Page 111
Design by contract......Page 112
Preconditions......Page 114
Postconditions......Page 115
Design by contract โ€“ conclusions......Page 116
Defensive programming......Page 117
Error handling......Page 118
Value substitution......Page 119
Exception handling......Page 120
Using assertions in Python......Page 128
Separation of concerns......Page 131
Cohesion and coupling......Page 132
Acronyms to live by......Page 133
DRY/OAOO......Page 134
YAGNI......Page 136
KIS......Page 138
EAFP/LBYL......Page 140
Inheritance in Python......Page 141
When inheritance is a good decision......Page 142
Anti-patterns for inheritance......Page 143
Method Resolution Order (MRO)......Page 147
Mixins......Page 149
How function arguments work in Python......Page 151
How arguments are copied to functions......Page 152
Variable number of arguments......Page 153
Positional-only parameters......Page 159
Keyword-only arguments......Page 161
The number of arguments in functions......Page 162
Function arguments and coupling......Page 163
Compact function signatures that take too many arguments......Page 164
Orthogonality in software......Page 166
Structuring the code......Page 168
Summary......Page 170
References......Page 171
The SOLID Principles......Page 173
The single responsibility principle......Page 174
A class with too many responsibilities......Page 175
Distributing responsibilities......Page 176
The open/closed principle......Page 178
Example of maintainability perils for not following the OCP......Page 179
Refactoring the events system for extensibility......Page 182
Extending the events system......Page 184
Liskov's substitution principle......Page 186
Using mypy to detect incorrect method signatures......Page 188
Detecting incompatible signatures with pylint......Page 190
More subtle cases of LSP violations......Page 191
Remarks on the LSP......Page 194
Interface segregation......Page 195
The smaller the interface, the better......Page 197
How small should an interface be?......Page 199
Dependency inversion......Page 200
A case of rigid dependencies......Page 201
Inverting the dependencies......Page 202
Dependency injection......Page 203
Summary......Page 206
References......Page 208
Using Decorators to Improve Our Code......Page 209
What are decorators in Python?......Page 210
Function decorators......Page 211
Decorators for classes......Page 213
Other types of decorator......Page 217
Passing arguments to decorators......Page 218
Decorators with nested functions......Page 219
Decorator objects......Page 221
Decorators with default values......Page 223
Decorators for coroutines......Page 226
Extended syntax for decorators......Page 229
Good uses for decorators......Page 230
Adapting function signatures......Page 231
Tracing code......Page 233
Preserving data about the original wrapped object......Page 234
Incorrect handling of side effects in a decorator......Page 237
Requiring decorators with side effects......Page 240
Creating decorators that will always work......Page 242
Decorators and clean code......Page 245
Composition over inheritance......Page 246
The DRY principle with decorators......Page 249
Decorators and separation of concerns......Page 251
Analysis of good decorators......Page 253
Summary......Page 254
References......Page 255
A first look at descriptors......Page 257
The machinery behind descriptors......Page 258
The get method......Page 262
The set method......Page 264
The delete method......Page 266
The set name method......Page 269
Non-data descriptors......Page 271
Data descriptors......Page 274
An application of descriptors......Page 277
A first attempt without using descriptors......Page 278
The idiomatic implementation......Page 279
Different forms of implementing descriptors......Page 282
The issue of shared state......Page 283
Accessing the dictionary of the object......Page 284
Using weak references......Page 285
Reusing code......Page 286
An alternative to class decorators......Page 287
Analysis of descriptors......Page 291
Functions and methods......Page 292
Built-in decorators for methods......Page 296
Slots......Page 298
Implementing descriptors in decorators......Page 299
Interface of descriptors......Page 300
Object-oriented design of the descriptors......Page 301
Summary......Page 302
References......Page 303
Generators, Iterators, and Asynchronous Programming......Page 305
Creating generators......Page 306
A first look at generators......Page 307
Generator expressions......Page 310
Idioms for iteration......Page 312
The next() function......Page 315
Using a generator......Page 316
Itertools......Page 317
Simplifying code through iterators......Page 318
The iterator pattern in Python......Page 321
Coroutines......Page 326
close()......Page 327
throw(ex_type[, ex_value[, ex_traceback]])......Page 328
send(value)......Page 330
Returning values in coroutines......Page 334
Delegating into smaller coroutines โ€“ the 'yield from' syntax......Page 336
Asynchronous programming......Page 342
Magic asynchronous methods......Page 345
Asynchronous context managers......Page 346
Other magic methods......Page 347
Asynchronous iteration......Page 348
Asynchronous generators......Page 351
References......Page 353
Unit Testing and Refactoring......Page 355
Design principles and unit testing......Page 356
A note about other forms of automated testing......Page 357
Unit testing and agile software development......Page 359
Unit testing and software design......Page 360
Defining the boundaries of what to test......Page 364
Frameworks and libraries for unit testing......Page 365
unittest......Page 367
pytest......Page 373
Code coverage......Page 378
Mock objects......Page 382
Refactoring......Page 389
Evolving our code......Page 390
Production code isn't the only one that evolves......Page 392
More about testing......Page 394
Mutation testing......Page 395
Boundaries or limit values......Page 398
Classes of equivalence......Page 399
Edge cases......Page 400
A brief introduction to test-driven development......Page 401
Summary......Page 402
References......Page 403
Common Design Patterns......Page 404
Design pattern considerations in Python......Page 405
Design patterns in action......Page 406
Singleton and shared state (monostate)......Page 408
Adapter......Page 415
Composite......Page 418
Decorator......Page 419
Facade......Page 422
Chain of responsibility......Page 424
The template method......Page 427
Command......Page 428
State......Page 430
The null object pattern......Page 435
Final thoughts about design patterns......Page 438
The influence of patterns over the design......Page 439
Design patterns as theory......Page 440
Names in our models......Page 441
References......Page 442
From clean code to clean architecture......Page 444
Separation of concerns......Page 446
Monolithic applications and microservices......Page 447
Abstractions......Page 449
Software components......Page 450
Packages......Page 451
Managing dependencies......Page 455
Other considerations when managing dependencies......Page 457
Artifact versions......Page 459
Docker containers......Page 460
Use case......Page 462
Domain models......Page 463
Calling from the application......Page 465
Adapters......Page 467
The services......Page 468
Analysis......Page 471
Limitations......Page 472
Testability......Page 473
Summary......Page 474
References......Page 475
Summing it all up......Page 476
Other Books You May Enjoy......Page 478
Index......Page 480


๐Ÿ“œ SIMILAR VOLUMES


Clean Code in Python: Develop maintainab
โœ Mariano Anaya ๐Ÿ“‚ Library ๐Ÿ“… 2021 ๐Ÿ› Packt Publishing ๐ŸŒ English

Code <p><b>Tackle inefficiencies and errors the Pythonic way</b></p><h4>Key Features</h4><ul><li>Enhance your coding skills using the new features introduced in Python 3.9</li><li>Implement the refactoring techniques and SOLID principles in Python</li><li>Apply microservices to your legacy systems

Clean Code in Python: Develop maintainab
โœ Mariano Anaya ๐Ÿ“‚ Library ๐Ÿ“… 2021 ๐Ÿ› Packt Publishing Ltd ๐ŸŒ English

<p><b>Improve your software engineering practices to tackle inefficiencies, errors, and other perils that emerge due to bad code</b></p>Key Features<ul><li>Enhance your coding skills to increase efficiency as well as reflect the new features introduced in Python 3.9</li><li>Understand how to apply m

Python Clean Code: Best Practices and Te
โœ Nash Maverick ๐Ÿ“‚ Library ๐Ÿ“… 2023 ๐Ÿ› Vigilant Vaults ๐ŸŒ English

<p><span>"</span><span>Python Clean Code</span><span>" is a comprehensive guidebook for Python developers who want to improve the quality of their code by adopting best practices for writing clean, readable, and maintainable code. The book is authored by </span><span>Nash Maverick</span><span>, who

Python Clean Code: Best Practices and Te
โœ Nash Maverick ๐Ÿ“‚ Library ๐Ÿ“… 2023 ๐Ÿ› Vigilant Vaults ๐ŸŒ English

<p><span>"</span><span>Python Clean Code</span><span>" is a comprehensive guidebook for Python developers who want to improve the quality of their code by adopting best practices for writing clean, readable, and maintainable code. The book is authored by </span><span>Nash Maverick</span><span>, who

Robust Python: Write Clean and Maintaina
โœ Patrick Viafore ๐Ÿ“‚ Library ๐Ÿ“… 2021 ๐Ÿ› O'Reilly Media ๐ŸŒ English

Does it seem like your Python projects are getting bigger and bigger? Are you feeling the pain as your codebase expands and gets tougher to debug and maintain? Python is an easy language to learn and use, but that also means systems can quickly grow beyond comprehension. Thankfully, Python has featu