HAPPY BOOKSGIVING
Use code BOOKSGIVING during checkout to save 40%-55% on books and eBooks. Shop now.
Register your product to gain access to bonus material or receive a coupon.
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
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.
Regular Expressions in Python 3
Introduction 1
Chapter 1: Rapid Introduction to Procedural Programming 7
Creating and Running Python Programs 7
Python’s “Beautiful Heart” 12
Examples 36
Summary 42
Exercises 44
Chapter 2:Data Types 47
Identifiers and Keywords 47
Integral Types 50
Floating-Point Types 54
Strings 61
Examples 88
Summary 95
Exercises 97
Chapter 3: Collection Data Types 99
Sequence Types 99
Set Types 112
Mapping Types 117
Iterating and Copying Collections 127
Examples 138
Summary 146
Exercises 147
Chapter 4: Control Structures and Functions 149
Control Structures 149
Exception Handling 153
Custom Functions 161
Example: make_html_skeleton.py 175
Summary 181
Exercise 182
Chapter 5: Modules 185
Modules and Packages 185
Overview of Python’s Standard Library 202
Summary 219
Exercise 220
Chapter 6: Object-Oriented Programming 223
The Object-Oriented Approach 224
Custom Classes 228
Custom Collection Classes 251
Summary 272
Exercises 274
Chapter 7: File Handling 277
Writing and Reading Binary Data 282
Writing and Parsing Text Files 294
Writing and Parsing XML Files 302
Random Access Binary Files 313
Summary 326
Exercises 327
Chapter 8: Advanced Programming Techniques 329
Further Procedural Programming 330
Further Object-Oriented Programming 353
Functional-Style Programming 384
Example: Valid.py 388
Summary 390
Exercises 392
Chapter 9: Processes and Threading 395
Delegating Work to Processes 396
Delegating Work to Threads 400
Summary 409
Exercises 410
Chapter 10: Networking 413
Creating a TCP Client 414
Creating a TCP Server 420
Summary 427
Exercises 427
Chapter 11: Database Programming 431
DBM Databases 432
SQL Databases 436
Summary 443
Exercise 444
Chapter 12: Regular Expressions 445
Python’s Regular Expression Language 446
The Regular Expression Module 455
Summary 464
Exercises 465
Chapter 13: Introduction to GUI Programming 467
Dialog-Style Programs 470
Main-Window-Style Programs 476
Summary 491
Exercises 491
Epilogue 493
Index 495