Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Mastering Object-Oriented Python

You're reading from   Mastering Object-Oriented Python Build powerful applications with reusable code using OOP design patterns and Python 3.7

Arrow left icon
Product type Paperback
Published in Jun 2019
Publisher Packt
ISBN-13 9781789531367
Length 770 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Steven F. Lott Steven F. Lott
Author Profile Icon Steven F. Lott
Steven F. Lott
Arrow right icon
View More author details
Toc

Table of Contents (25) Chapters Close

Preface
Who this book is for
What this book covers
To get the most out of this book
Get in touch
1. Preliminaries, Tools, and Techniques FREE CHAPTER 2. The __init__() Method 3. Integrating Seamlessly - Basic Special Methods 4. Attribute Access, Properties, and Descriptors 5. The ABCs of Consistent Design 6. Using Callables and Contexts 7. Creating Containers and Collections 8. Creating Numbers 9. Decorators and Mixins - Cross-Cutting Aspects 10. Serializing and Saving - JSON, YAML, Pickle, CSV, and XML 11. Storing and Retrieving Objects via Shelve 12. Storing and Retrieving Objects via SQLite 13. Transmitting and Sharing Objects 14. Configuration Files and Persistence 15. Design Principles and Patterns 16. The Logging and Warning Modules 17. Designing for Testability 18. Coping with the Command Line 19. Module and Package Design 20. Quality and Documentation

Interaction, scripting, and tools

Python is often described as Batteries Included programming. Everything required is available directly as part of a single download. This provides the runtime, the standard library, and the IDLE editor as a simple development environment.

It's very easy to download and install Python 3.7 and start running it interactively on the desktop. The example in the previous section included the >>> prompt from interactive Python. 

If you're using the Iron Python (IPython) implementation, the interaction will look like this:

In [1]: f = [1, 1, 2, 3]
In [3]: f += [f[-1] + f[-2]]
In [4]: f
Out[4]: [1, 1, 2, 3, 5]

The prompt is slightly different, but the language is the same. Each statement is evaluated as it is presented to Python. 

This is handy for some experimentation. Our goal is to build tools, frameworks, and applications. While many of the examples will be shown in an interactive style, most of the actual programming will be via script files.

Running examples interactively makes a profound statement. Well-written Python code should be simple enough that it can be run from the command line.

Good Python is simple. We should be able to demonstrate a design at the >>> prompt.

Interactive use is not our goal. Exercising code from the >>> prompt is a quality test for complexity. If the code is too complex to exercise it from the >>> prompt, then refactoring is needed.

The focus of this book is on creating complete scripts, modules, packages, and applications. Even though some examples are shown in interactive mode, the objective is to create Python files. These files may be as simple as a script or as complex as a directory with files to create a web application.

Tools such as mypy, pytest, and pylint work with Python files. Preparing script files can be done with almost any text editor. It's best, however, to work with an IDE, where a number of tools can be provided to help develop applications and scripts.

You have been reading a chapter from
Mastering Object-Oriented Python - Second Edition
Published in: Jun 2019
Publisher: Packt
ISBN-13: 9781789531367
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime
Banner background image