Secret Recipes of the Python Ninja: Over 70 recipes that uncover powerful programming tactics in Python

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Author(s): Cody Jackson
Year: 2018

Language: English
Tags: coding, programming, computer science, mathematics, logic, math, maths

Cover
Copyright and Credits
Packt Upsell
Contributors
Table of Contents
Preface
Chapter 1: Working with Python Modules
Introduction
Using and importing modules and namespaces
How to do it...
How it works...
There's more...
Implementing virtual Python environments
Getting ready
How to do it...
How it works...
There's more...
Python package installation options
How to do it...
How it works...
Utilizing requirement files and resolving conflicts
How to do it...
How it works...
There's more...
Using local patches and constraint files
How to do it...
How it works...
There's more...
Working with packages
How to do it...
How it works...
There's more...
Creating wheels and bundles
How to do it...
How it works...
There's more...
Comparing source code to bytecode
How to do it...
How it works...
There's more...
How to create and reference module packages
How to do it...
How it works...
There's more...
Operating system-specific binaries
How to do it...
There's more...
How to upload programs to PyPI
Getting ready
How to do it...
How it works...
Project packaging
How to do it...
Uploading to PyPI
Getting ready
How to do it...
How it works...
Chapter 2: Utilizing the Python Interpreter
Introduction
Launching Python environments
How to do it...
How it works...
Utilizing Python command options
How to do it...
How it works...
Interface options
Generic options
Miscellaneous options
See also...
Working with environment variables
How to do it...
How it works...
Making scripts executable
How to do it...
There's more...
Modifying interactive interpreter startup
How to do it...
See also
Alternative Python implementations
How to do it...
There's more...
Installing Python on Windows
Getting ready
How to do it...
Using the Windows Python launcher
How to do it...
Embedding Python with other applications
How to do it...
How it works...
Using alternative Python shells – IPython
Getting ready
How to do it...
There's more...
Using alternative Python shells – bpython
Getting ready
How to do it...
There's more...
Using alternative Python shells – DreamPie
Getting ready
How to do it...
There's more...
Chapter 3: Working with Decorators
Introduction
Reviewing functions
How to do it...
How it works...
Introducing decorators
How to do it...
How it works...
Using function decorators
How to do it...
How it works...
Using class decorators
How to do it...
Examples of decorators
Getting ready
How to do it...
How it works...
There's more...
Using the decorators module
How to do it...
How it works...
There's more...
See also
Chapter 4: Using Python Collections
Introduction
Reviewing containers
How to do it...
There's more...
Lists and tuples
Dictionaries
Sets
Implementing namedtuple
How to do it...
There's more...
Implementing deque
How to do it...
Implementing ChainMap
How to do it...
Implementing Counters
How to do it...
There's more...
Implementing OrderedDict
How to do it...
Implementing defaultdict
How to do it...
Implementing UserDict
How to do it...
Implementing UserList
How to do it...
There's more...
Implementing UserString
How to do it...
Improving Python collections
How to do it...
Default dictionaries
Named tuples
Ordered dictionaries
Looking at the collections – extended module
Getting ready
How to do it...
setlist
bags
RangeMap
Bijection
Chapter 5: Generators, Coroutines, and Parallel Processing
How iteration works in Python
How to do it...
Using the itertools module
How to do it...
Infinite iterators
Combinatoric iterators
Terminating iterators
Using generator functions
How to do it...
How it works...
There's more...
Simulating multithreading with coroutines
How to do it...
There's more...
When to use parallel processing
How to do it...
There's more...
Forking processes
How to do it...
How it works...
There's more...
How to implement multithreading
How to do it...
There's more...
Advantages
Disadvantages
How to implement multiprocessing
How to do it...
There's more...
Chapter 6: Working with Python's Math Module
Using the math module's functions and constants
How to do it...
Working with complex numbers
How to do it...
Improving decimal numbers
How to do it...
Increasing accuracy with fractions
How to do it...
Working with random numbers
How to do it...
Using the secrets module
How to do it...
Implementing basic statistics
How to do it...
Improving functionality with comath
Getting ready
How to do it...
Chapter 7: Improving Python Performance with PyPy
Introduction
What is PyPy?
Getting ready
How to do it...
There's more...
What is RPython?
How to do it...
Flow restrictions
Object restrictions
Integer types
There's more...
Some real-world examples
How to do it...
There's more...
Chapter 8: Python Enhancement Proposals
Introduction
What are PEPs?
How to do it...
There's more...
PEP 556 – Threaded garbage collection
Getting ready
How to do it...
There's more...
PEP 554 – Multiple subinterpreters
How to do it...
How it works...
Channels
There's more...
PEP 551 – Security transparency
Getting ready
General security
Python and security
How to do it...
PEP 543 – Unified TLS API
How to do it...
There's more...
Chapter 9: Documenting with LyX
Introduction
Python documentation tools and techniques
How to do it...
Inline comments and the dir command
Using docstrings
How to do it...
There's more...
Using PyDoc help
How to do it...
HTML reports
How to do it...
Using reStructuredText files
Getting ready
How to do it...
Using the Sphinx documentation program
Getting ready
How to do it...
Using LaTeX and LyX document preparation programs
Getting ready
How to do it...
There's more...
Other Books You May Enjoy
Index