Modern Python Cookbook
Book
eBook
$41.99
$28.99
Print
$51.99
Subscription
$15.99
$10 p/m for three months
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
What do I get with Print?
Get a paperback copy of the book delivered to your specified Address*
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do I get with Print?
What do you get with video?
What do you get with video?
What do you get with Audiobook?
What do you get with Exam Trainer?
eBook
$41.99
$28.99
Print
$51.99
Subscription
$15.99
$10 p/m for three months
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do I get with Print?
Get a paperback copy of the book delivered to your specified Address*
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do I get with Print?
Get a paperback copy of the book delivered to your specified Address*
Access this title in our online reader
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
-
Free ChapterNumbers, Strings, and Tuples
- Numbers, Strings, and Tuples
- Introduction
- Creating meaningful names and using variables
- Working with large and small integers
- Choosing between float, decimal, and fraction
- Choosing between true division and floor division
- Rewriting an immutable string
- String parsing with regular expressions
- Building complex strings with "template".format()
- Building complex strings from lists of characters
- Using the Unicode characters that aren't on our keyboards
- Encoding strings – creating ASCII and UTF-8 bytes
- Decoding bytes – how to get proper characters from some bytes
- Using tuples of items
-
Statements and Syntax
- Statements and Syntax
- Introduction
- Writing Python script and module files – syntax basics
- Writing long lines of code
- Including descriptions and documentation
- Writing better RST markup in docstrings
- Designing complex if...elif chains
- Designing a while statement which terminates properly
- Avoiding a potential problem with break statements
- Leveraging the exception matching rules
- Avoiding a potential problem with an except: clause
- Chaining exceptions with the raise from statement
- Managing a context using the with statement
-
Function Definitions
- Function Definitions
- Introduction
- Designing functions with optional parameters
- Using super flexible keyword parameters
- Forcing keyword-only arguments with the * separator
- Writing explicit types on function parameters
- Picking an order for parameters based on partial functions
- Writing clear documentation strings with RST markup
- Designing recursive functions around Python's stack limits
- Writing reusable scripts with the script library switch
-
Built-in Data Structures – list, set, dict
- Built-in Data Structures – list, set, dict
- Introduction
- Choosing a data structure
- Building lists – literals, appending, and comprehensions
- Slicing and dicing a list
- Deleting from a list – deleting, removing, popping, and filtering
- Reversing a copy of a list
- Using set methods and operators
- Removing items from a set – remove(), pop(), and difference
- Creating dictionaries – inserting and updating
- Removing from dictionaries – the pop() method and the del statement
- Controlling the order of dict keys
- Handling dictionaries and sets in doctest examples
- Understanding variables, references, and assignment
- Making shallow and deep copies of objects
- Avoiding mutable default values for function parameters
-
User Inputs and Outputs
-
Basics of Classes and Objects
- Basics of Classes and Objects
- Introduction
- Using a class to encapsulate data and processing
- Designing classes with lots of processing
- Designing classes with little unique processing
- Optimizing small objects with __slots__
- Using more sophisticated collections
- Extending a collection – a list that does statistics
- Using properties for lazy attributes
- Using settable properties to update eager attributes
-
More Advanced Class Design
- More Advanced Class Design
- Introduction
- Choosing between inheritance and extension – the is-a question
- Separating concerns via multiple inheritance
- Leveraging Python's duck typing
- Managing global and singleton objects
- Using more complex structures – maps of lists
- Creating a class that has orderable objects
- Defining an ordered collection
- Deleting from a list of mappings
-
Input/Output, Physical Format, and Logical Layout
- Input/Output, Physical Format, and Logical Layout
- Introduction
- Using pathlib to work with filenames
- Reading and writing files with context managers
- Replacing a file while preserving the previous version
- Reading delimited files with the CSV module
- Reading complex formats using regular expressions
- Reading JSON documents
- Reading XML documents
- Reading HTML documents
- Upgrading CSV from DictReader to namedtuple reader
- Upgrading CSV from a DictReader to a namespace reader
- Using multiple contexts for reading and writing files
-
Testing
- Testing
- Introduction
- Using docstrings for testing
- Testing functions that raise exceptions
- Handling common doctest issues
- Creating separate test modules and packages
- Combining unittest and doctest tests
- Testing things that involve dates or times
- Testing things that involve randomness
- Mocking external resources
-
Web Services
-
Application Integration
- Application Integration
- Introduction
- Finding configuration files
- Using YAML for configuration files
- Using Python for configuration files
- Using class-as-namespace for configuration
- Designing scripts for composition
- Using logging for control and audit output
- Combining two applications into one
- Combining many applications using the Command design pattern
- Managing arguments and configuration in composite applications
- Wrapping and combining CLI applications
- Wrapping a program and checking the output
- Controlling complex sequences of steps
About this
book
Python is the preferred choice of developers, engineers, data scientists, and hobbyists everywhere. It is a great scripting language that can power your applications and provide great speed, safety, and scalability. By exposing Python as a series of simple recipes, you can gain insight into specific language features in a particular context. Having a tangible context helps make the language or standard library feature easier to understand.
This book comes with over 100 recipes on the latest version of Python. The recipes will benefit everyone ranging from beginner to an expert. The book is broken down into 13 chapters that build from simple language concepts to more complex applications of the language.
The recipes will touch upon all the necessary Python concepts related to data structures, OOP, functional programming, as well as statistical programming. You will get acquainted with the nuances of Python syntax and how to effectively use the advantages that it offers. You will end the book equipped with the knowledge of testing, web services, and configuration and application integration tips and tricks.
The recipes take a problem-solution approach to resolve issues commonly faced by Python programmers across the globe. You will be armed with the knowledge of creating applications with flexible logging, powerful configuration, and command-line options, automated unit tests, and good documentation.
- Publication date:
- November 2016
- Publisher
- Packt
- Pages
- 692
- ISBN
- 9781786469250
Latest Reviews
(7 reviews total)