Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Python Essentials

You're reading from   Python Essentials Modernize existing Python code and plan code migrations to Python using this definitive guide

Arrow left icon
Product type Paperback
Published in Jun 2015
Publisher Packt
ISBN-13 9781784390341
Length 298 pages
Edition 1st Edition
Languages
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 (17) Chapters Close

Preface 1. Getting Started FREE CHAPTER 2. Simple Data Types 3. Expressions and Output 4. Variables, Assignment and Scoping Rules 5. Logic, Comparisons, and Conditions 6. More Complex Data Types 7. Basic Function Definitions 8. More Advanced Functions 9. Exceptions 10. Files, Databases, Networks, and Contexts 11. Class Definitions 12. Scripts, Modules, Packages, Libraries, and Applications 13. Metaprogramming and Decorators 14. Fit and Finish – Unit Testing, Packaging, and Documentation 15. Next Steps Index

What this book covers

Chapter 1, Getting Started, addresses installing or upgrading Python. We explore Python's Read-Evaluate-Print Loop (REPL) as a way to interact with the language. We'll use this interactive Python mode as a way to explore most of the language features.

Chapter 2, Simple Data Types, introduces a few features concerning numbers and some simple collections. We'll look at Python's Unicode strings as well as byte strings, including some of the conversions between strings and numbers.

Chapter 3, Expressions and Output, provides more details on Python expression syntax and how the various numeric types relate to each other. We'll look at the coercion rules and the numeric tower. We'll look at the print() function, which is a common tool for looking at output.

Chapter 4, Variables, Assignment and Scoping Rules, shows how we assign names to objects. We look at a number of different assignment statements available in Python. We also explore the input() function, which parallels the print() function.

Chapter 5, Logic, Comparisons, and Conditions, shows the logical operators and literals that Python uses. We'll look at the comparison operators and how we use them. We'll look closely at the if statement.

Chapter 6, More Complex Data Types, shows the core features of the list, set, and dict built-in types. We use the for statement to work with these collections. We also use functions such as sum(), map(), and filter().

Chapter 7, Basic Function Definitions, introduces the syntax for the def statement as well as the return statement. Python offers a wide variety of ways to provide argument values to functions; we show a few of the alternatives.

Chapter 8, More Advanced Functions, extends the basic function definitions to include the yield statement. This allows us to write generator functions that will iterate over a sequence of data values. We look at a few functional programming features available via built-in functions as well as the modules in the Python Standard Library.

Chapter 9, Exceptions, shows how we handle and raise exceptions. This allows us to write programs which are considerably more flexible. A simple "happy path" can handle the bulk of the processing, and exception clauses can handle rare or unexpected alternative paths.

Chapter 10, Files, Databases, Networks, and Contexts, will introduce a number of features related to persistent storage. We'll look at Python's use of files and file-like objects. We'll also extend the concept of persistence to include some database features available in the Python Standard Library. This chapter will also include a review of the with statement for context management.

Chapter 11, Class Definitions, demonstrates the class statement and the essentials of object-oriented programming. We look at the basics of inheritance and how to define class-level (static) methods.

Chapter 12, Scripts, Modules, Packages, Libraries, and Applications, shows different ways in which we can create Python code files. We'll look at the formal structures of script, module, and package. We'll also look at informal concepts such as application, library, and framework.

Chapter 13, Metaprogramming and Decorators, introduces two concepts that can help us write Python code that manipulates Python code. Python makes metaprogramming relatively simple; we can leverage this to simplify certain types of programming where a common aspect doesn't fit neatly into a class hierarchy or library of functions.

Chapter 14, Fit and Finish – Unit Testing, Packaging, and Documentation, moves beyond the Python language into the idea of creating a complete, polished product. Any well-written program should include test cases and documentation. We show common ways to make sure this is done properly.

Chapter 15, Next Steps, will demonstrate four simple kinds of applications. We'll look at the command-line interface (CLI), graphic user interface (GUI), simple Web frameworks, as well as MapReduce applications.

lock icon The rest of the chapter is locked
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 $19.99/month. Cancel anytime
Banner background image