“Hellmann’s writing has become an indispensable resource for me and many others as it fills a critical gap in Python Documentation with examples.” — Jesse Noller, Python Core Developer and PSF Board Member Master the Powerful Python Standard Library through Real Code Examples The Python Standard Library contains hundreds of modules for interacting with the operating system, interpreter, and Internet—all extensively tested and ready to jump-start your application development. The Python Standard Library by Example introduces virtually every important area of the Python 2.7 library through concise, stand-alone source code/output examples, designed for easy learning and reuse. Building on his popular Python Module of the Week blog series, author and Python expert Doug Hellmann focuses on “showing” not “telling.” He explains code behavior through downloadable examples that fully demonstrate each feature. You’ll find practical code for working with text, data types, algorithms, math, file systems, networking, the Internet, XML, email, cryptography, concurrency, runtime and language services, and much more. Each section fully covers one module, and links to valuable additional resources, making this book an ideal tutorial and reference. Coverage includes Manipulating text with string, textwrap, re, and difflib Implementing data structures: collections, array, queue, struct, copy, and more Reading, writing, and manipulating files and directories Regular expression pattern matching Exchanging data and providing for persistence Archiving and data compression Managing processes and threads Using application “building blocks”: parsing command-line options, prompting for passwords, scheduling events, and logging Testing, debugging, and compilation Controlling runtime configuration Using module and package utilities If you’re new to Python, this book will quickly give you access to a whole new world of functionality. If you’ve worked with Python before, you’ll discover new, powerful solutions and better ways to use the modules you’ve already tried.
An innovative reference reveals the many capabilites of the Python Standard Library, which is a compilation of commonly used procedures that can be pasted into a Python script, by providing over 300 real-world example scripts. Original. (Intermediate/Advanced)
Practical Python 3 for experienced developers: use the right idioms, techniques, and features to write great code * *Written from a completely 'Python 3' point of view: teaches best practices for making the most of today's newest version of Python. *Designed to help developers get productive fast... then learn how to write any program, use any library, create any library module. *Includes expert guidance on migrating Python 2 code to Python 3. Around the world, programmers appreciate Python for its simplicity, power, expressiveness, and the sheer pleasure of writing Python code. Python 3.1 is the newest and best version of the language yet: more convenient, more consistent, and easier to use. Mark Summerfield demonstrates how to write code that takes full advantage of the latest Python 3 features and idioms. Programming in Python 3, 2/e, brings together all the knowledge needed to write programs, use any library, and even create new library modules. The book teaches every aspect of the Python 3 language. It covers all the built-in functionality, as well as key components of Python's standard library. Structured so readers can write Python programs from chapter 1, each subsequent chapter provides further depth and broader coverage. Two new chapters have been added to this edition increasing the coverage to include parsing, debugging, testing, and profiling. Readers will master Python procedural and object-oriented techniques; creation of custom modules and packages; writing and reading files; multithreading; networking; database programming; GUIs; regular expressions; application debugging, testing, and profiling; and more. Detailed appendices include coverage of migrating applications from Python 2 to Python 3, plus a complete language reference. All sample code has been tested with the final version of Python 3 on Windows, Linux, and Mac OS X.
Create Better Programs Using Concurrency, Libraries, and Patterns
Author: Mark Summerfield
Winner of the 2014 Jolt Award for "Best Book" “Whether you are an experienced programmer or are starting your career, Python in Practice is full of valuable advice and example to help you improve your craft by thinking about problems from different perspectives, introducing tools, and detailing techniques to create more effective solutions.” —Doug Hellmann, Senior Developer, DreamHost If you’re an experienced Python programmer, Python in Practice will help you improve the quality, reliability, speed, maintainability, and usability of all your Python programs. Mark Summerfield focuses on four key themes: design patterns for coding elegance, faster processing through concurrency and compiled Python (Cython), high-level networking, and graphics. He identifies well-proven design patterns that are useful in Python, illuminates them with expert-quality code, and explains why some object-oriented design patterns are irrelevant to Python. He also explodes several counterproductive myths about Python programming—showing, for example, how Python can take full advantage of multicore hardware. All examples, including three complete case studies, have been tested with Python 3.3 (and, where possible, Python 3.2 and 3.1) and crafted to maintain compatibility with future Python 3.x versions. All code has been tested on Linux, and most code has also been tested on OS X and Windows. All code may be downloaded at www.qtrac.eu/pipbook.html. Coverage includes Leveraging Python’s most effective creational, structural, and behavioral design patterns Supporting concurrency with Python’s multiprocessing, threading, and concurrent.futures modules Avoiding concurrency problems using thread-safe queues and futures rather than fragile locks Simplifying networking with high-level modules, including xmlrpclib and RPyC Accelerating Python code with Cython, C-based Python modules, profiling, and other techniques Creating modern-looking GUI applications with Tkinter Leveraging today’s powerful graphics hardware via the OpenGL API using pyglet and PyOpenGL
Refine your programming techniques and approaches to become a more productive and creative Python programmer. This book explores the concepts and features that will improve not only your code but also your understanding of the Python community with insights and details about the Python philosophy. Pro Python 3, Third Edition gives you the tools to write clean, innovative code. It starts with a review of some core Python principles, which are illustrated by various concepts and examples later in the book. The first half of the book explores aspects of functions, classes, protocols, and strings, describing techniques which may not be common knowledge, but which together form a solid foundation. Later chapters cover documentation, testing, and app distribution. Along the way, you’ll develop a complex Python framework that incorporates ideas learned throughout the book. Updates in this edition include the role of iterators in Python 3, web scraping with Scrapy and BeautifulSoup, using Requests to call web pages without strings, new tools for distribution and installation, and much more. By the end of the book you'll be ready to deploy uncommon features that can take your skills to the next level in Python. What You’ll Learn Implement programs with various types of Python functions Work with classes and object-oriented programming Use strings from the standard library and third-party libraries Harvest web site data with Python Automate unit testing by writing a test suite Review imaging, random number generation, and NumPy scientific extensions Understand The Zen of Python documentation to help you decide the best way to distribute your code Who This Book Is For Intermediate programmers familiar with Python who are looking to move to an advanced level. You should have written at least a simple Python application, and be comfortable with a basic object-oriented approach, using the interactive interpreter, and writing control structures.
Foundations of Python Network Programming, Third Edition, covers all of the classic topics found in the second edition of this book, including network protocols, network data and errors, email, server architecture, and HTTP and web applications, plus updates for Python 3. Some of the new topics in this edition include: • Extensive coverage of the updated SSL support in Python 3 • How to write your own asynchronous I/O loop. • An overview of the "asyncio" framework that comes with Python 3.4. • How the Flask web framework connects URLs to your Python code. • How cross-site scripting and cross-site request forgery can be used to attack your web site, and how to protect against them. • How a full-stack web framework like Django can automate the round trip from your database to the screen and back. If you're a Python programmer who needs a deep understanding of how to use Python for network-related tasks and applications, this is the book for you. From web application developers, to systems integrators, to system administrators—this book has everything that you need to know.
Advanced Guide to Python 3 Programming delves deeply into a host of subjects that you need to understand if you are to develop sophisticated real-world programs. Each topic is preceded by an introduction followed by more advanced topics, along with numerous examples, that take you to an advanced level. There are nine different sections within the book covering Computer Graphics (including GUIs), Games, Testing, File Input and Output, Databases Access, Logging, Concurrency and Parallelism, Reactive programming, and Networking. Each section is self-contained and can either be read on its own or as part of the book as a whole. This book is aimed at the those who have learnt the basics of the Python 3 language but want to delve deeper into Python’s eco system of additional libraries and modules, to explore concurrency and parallelism, to create impressive looking graphical interfaces, to work with databases and files and to provide professional logging facilities.