Mastering Python: 50 Specific Tips for Writing Better Code: Practical Strategies for Writing High-Quality Python Code 9798865196815

Unlock the Secrets to Python Mastery! Are you ready to take your Python coding skills to the next level? Look no furthe

153 27 2MB

English Pages 345 Year 2023

Report DMCA / Copyright

DOWNLOAD EPUB FILE

Table of contents :
Chapter 1:
Introduction

The Zen of Python

Pythonic thinking

Chapter 2:
Pythonic thinking

Know your data structures

Tuples

Lists

Dictionaries

Sets

Arrays

Queues

Stacks

Heaps

Trees

Graphs

Write expressive code

Choosing good names

Avoiding magic numbers and strings

Using list comprehensions and generator expressions

Leveraging built-in functions

Using the with statement

Using decorators

Writing context managers

Take advantage of Python's features

Using named tuples

Leveraging closures

Using properties

Using descriptors

Using metaclasses

Writing idiomatic Python

Writing Pythonic loops

Using enumerate and zip

Using the ternary operator

Using multiple assignment

Using the walrus operator

Using context managers

Chapter 3:
Functions

Function basics

Function arguments and return values

Documenting functions

Writing doctests

Writing function annotations

Using default arguments

Using keyword arguments

Using *args and **kwargs

Function design

Writing pure functions

Writing functions with side effects

Writing functions that modify mutable arguments

Using the @staticmethod and @classmethod decorators

Using partial functions

Function decorators and closures

Writing simple decorators

Writing decorators that take arguments

Writing class decorators

Using closures

Using functools.partial

Chapter 4:
Classes and Objects

Class basics

Creating and using classes

Defining instance methods

Using instance variables

Understanding class vs instance data

Using slots for memory optimization

Understanding class inheritance

Using multiple inheritance

Class design

Writing clean, readable classes

Writing classes with a single responsibility

Using composition over inheritance

Using abstract base classes

Writing metaclasses

Advanced class topics

Using descriptors to customize attribute access

Using properties to control attribute access

Writing class decorators

Using the super function

Using slots to optimize memory usage

Chapter 5:
Concurrency and Parallelism

Threads and Processes

Understanding the Global Interpreter Lock (GIL)

Using threads for I/O-bound tasks

Using processes for CPU-bound tasks

Using multiprocessing

Using concurrent.futures

2. Coroutines and asyncio

Understanding coroutines

Using asyncio for I/O-bound tasks

Using asyncio for CPU-bound tasks

Using asyncio with third-party libraries

Debugging asyncio code

Chapter 6:
Built-in Modules

Collections

Using namedtuple

Using deque

Using defaultdict

Using OrderedDict

Using Counter

Using ChainMap

Using UserDict

Using UserList

Using UserString

Itertools

Using count, cycle, and repeat

Using chain, tee, and zip_longest

Using islice, dropwhile, and takewhile

Using groupby

Using starmap and product

File and Directory Access

Using os and os.path

Using pathlib

Using shutil

Using glob

Dates and Times

Using datetime

Using time

Using timedelta

Using pytz

Using dateutil

Serialization and Persistence

Using json

Using pickle

Using shelve

Using dbm

Using SQLite

Testing and Debugging

Writing unit tests

Using pytest

Debugging with pdb

Debugging with logging

Using assertions

Chapter 7:
Collaboration and Development

Code Quality

Using linters

Using type checkers

Using code formatters

Using docstring conventions

Writing maintainable code

Code Reviews

Conducting effective code reviews

Giving and receiving feedback

Improving code quality through reviews

Collaboration Tools

Using version control with Git

Using GitHub for collaboration

Using continuous integration

Using code coverage tools

Documentation and Packaging

Writing documentation

Using Sphinx

Packaging Python projects

Distributing Python packages

Managing dependencies

Mastering Python: 50 Specific Tips for Writing Better Code: Practical Strategies for Writing High-Quality Python Code
 9798865196815

  • 0 0 0
  • Like this paper and download? You can publish your own PDF file online for free in a few minutes! Sign Up
Recommend Papers