O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Programming in Python 3: A Complete Introduction to the Python Language

Book Description

Python 3 is the best version of the language yet: It is more powerful, convenient, consistent, and expressive than ever before. Now, leading Python programmer Mark Summerfield demonstrates how to write code that takes full advantage of Python 3’s features and idioms. The first book written from a completely “Python 3” viewpoint, Programming in Python 3 brings together all the knowledge you need to write any program, use any standard or third-party Python 3 library, and create new library modules of your own.

Summerfield draws on his many years of Python experience to share deep insights into Python 3 development you won’t find anywhere else. He begins by illuminating Python’s “beautiful heart”: the eight key elements of Python you need to write robust, high-performance programs. Building on these core elements, he introduces new topics designed to strengthen your practical expertise–one concept and hands-on example at a time. This book’s coverage includes

  • Developing in Python using procedural, object-oriented, and functional programming paradigms

  • Creating custom packages and modules

  • Writing and reading binary, text, and XML files, including optional compression, random access, and text and XML parsing

  • Leveraging advanced data types, collections, control structures, and functions

  • Spreading program workloads across multiple processes and threads

  • Programming SQL databases and key-value DBM files

  • Utilizing Python’s regular expression mini-language and module

  • Building usable, efficient, GUI-based applications

  • Advanced programming techniques, including generators, function and class decorators, context managers, descriptors, abstract base classes, metaclasses, and more

  • Programming in Python 3serves as both tutorial and language reference, and it is accompanied by extensive downloadable example code–all of it tested with the final version of Python 3 on Windows, Linux, and Mac OS X.

    Table of Contents

    1. Title Page
    2. Copyright Page
    3. Contents
    4. Developer’s Library
    5. List of Tables
    6. Introduction
      1. The Structure of the Book
      2. Obtaining and Installing Python 3
      3. Acknowledgments
    7. Chapter 1. Rapid Introduction to Procedural Programming
      1. Creating and Running Python Programs
      2. Python’s “Beautiful Heart”
      3. Examples
      4. Summary
      5. Exercises
    8. Chapter 2. Data Types
      1. Identifiers and Keywords
      2. Integral Types
      3. Floating-Point Types
      4. Strings
      5. Examples
      6. Summary
      7. Exercises
    9. Chapter 3. Collection Data Types
      1. Sequence Types
      2. Set Types
      3. Mapping Types
      4. Iterating and Copying Collections
      5. Examples
      6. Summary
      7. Exercises
    10. Chapter 4. Control Structures and Functions
      1. Control Structures
      2. Exception Handling
      3. Custom Functions
      4. Example: make_html_skeleton.py
      5. Summary
      6. Exercise
    11. Chapter 5. Modules
      1. Modules and Packages
      2. Overview of Python’s Standard Library
      3. Summary
      4. Exercises
    12. Chapter 6. Object-Oriented Programming
      1. The Object-Oriented Approach
      2. Custom Classes
      3. Custom Collection Classes
      4. Summary
      5. Exercises
    13. Chapter 7. File Handling
      1. Writing and Reading Binary Data
      2. Writing and Parsing Text Files
      3. Writing and Parsing XML Files
      4. Random Access Binary Files
      5. Summary
      6. Exercises
    14. Chapter 8. Advanced Programming Techniques
      1. Further Procedural Programming
      2. Further Object-Oriented Programming
      3. Functional-Style Programming
      4. Example: Valid.py
      5. Summary
      6. Exercises
    15. Chapter 9. Processes and Threading
      1. Delegating Work to Processes
      2. Delegating Work to Threads
      3. Summary
      4. Exercises
    16. Chapter 10. Networking
      1. Creating a TCP Client
      2. Creating a TCP Server
      3. Summary
      4. Exercises
    17. Chapter 11. Database Programming
      1. DBM Databases
      2. SQL Databases
      3. Summary
      4. Exercises
    18. Chapter 12. Regular Expressions
      1. Python’s Regular Expression Language
      2. The Regular Expression Module
      3. Summary
      4. Exercises
    19. Chapter 13. Introduction to GUI Programming
      1. Dialog-Style Programs
      2. Main-Window-Style Programs
      3. Summary
      4. Exercises
    20. Epilogue
    21. About the Author
      1. Production
    22. Index