Book description
Modernize existing Python code and plan code migrations to Python using this definitive guide
- Learn the essentials of Python programming to get you up and coding effectively
- Get up-to-speed with the most important built-in data structures in Python, using sequences, sets, and mappings
- Explore typical use cases for various features in Python through this compact guide
In Detail
Python Essentials provides a vital tour of the most critical features of Python. Starting with setup and installation, you will soon dive into exploring built-in-library types, Python's rich collection of operators and built-in functions, variables, assignment and scoping rules.
From this foundation, you will explore functions, a crucial aspect of any programming language, including considerable sophistication in defining parameters to a function and providing argument values. Explore advanced functional programming using generator expressions, comprehensions, and generator functions. Handle file input and output using web services and context managers, exception handling and explore wider, popular frameworks.
Through this concise and practical guide, you will explore all you need to know to leverage this powerful, and industry-standard, programming language.
What You Will Learn
- Use Python interactively and master the art of writing efficient Python scripts
- Learn techniques for working with string data, including how to use regular expressions to parse strings
- Get to know how the short-circuit and if-else logic operators work
- Explore mutable data structures including list, set, and dict
- Define functions with positional and optional parameters, and learn to use keyword argument values when calling a function
- Write generator functions, generator expressions, and comprehensions
- Master the use of exceptions for handling errors and other unexpected conditions
- Understand the importance of working with files, context manager, and the with statement
Table of contents
-
Python Essentials
- Table of Contents
- Python Essentials
- Credits
- About the Author
- About the Reviewers
- www.PacktPub.com
- Preface
- 1. Getting Started
- 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
- Looking at the five kinds of callables
- Defining functions with positional parameters
- Mutable and immutable argument values
- Defining optional parameters via default values
- Using the "everything else" notations of * and **
- Nested function definitions
- Working with namespaces
- Defining lambdas
- Writing additional function annotations
- Summary
-
8. More Advanced Functions
- Using the for statement with iterable collections
- Consequences and next steps
- Using generator expressions and comprehensions
- Defining generator functions with the yield statement
- Using the higher-order functions
- Using the built-in reductions – max, min, and reduce
- Three ways to sort a sequence
- Functional programming design patterns
- Summary
- 9. Exceptions
- 10. Files, Databases, Networks, and Contexts
-
11. Class Definitions
- Creating a class
- Writing the suite of statements in a class
- Using instance variables and methods
- Pythonic object-oriented programming
- Using properties
- Using inheritance to simplify class definitions
- Using class methods and attributes
- Using __slots__ to save storage
- The ABCs of abstract base classes
- Summary
- 12. Scripts, Modules, Packages, Libraries, and Applications
- 13. Metaprogramming and Decorators
- 14. Fit and Finish – Unit Testing, Packaging, and Documentation
- 15. Next Steps
- Index
Product information
- Title: Python Essentials
- Author(s):
- Release date: June 2015
- Publisher(s): Packt Publishing
- ISBN: 9781784390341
You might also like
book
Python in a Nutshell
Ask any Python aficionado and you'll hear that Python programmers have it all: an elegant language …
book
Getting Started with Python
Harness the power of Python objects and data structures to implement algorithms for analyzing your data …
book
Python One-Liners
Python One-Liners will teach you how to read and write “one-liners”: concise statements of useful functionality …
book
Python in a Nutshell, 2nd Edition
This book offers Python programmers one place to look when they needhelp remembering or deciphering the …