A guide to completing Python projects for those ready to take their skills to the next level
Python Projects is the ultimate resource for the Python programmer with basic skills who is ready to move beyond tutorials and start building projects.
The preeminent guide to bridge the gap between learning and doing, this book walks readers through the where and how of real-world Python programming with practical, actionable instruction. With a focus on real-world functionality, Python Projects details the ways that Python can be used to complete daily tasks and bring efficiency to businesses and individuals alike.
Python Projects is written specifically for those who know the Python syntax and lay of the land, but may still be intimidated by larger, more complex projects. The book provides a walk-through of the basic set-up for an application and the building and packaging for a library, and explains in detail the functionalities related to the projects. Topics include:
*How to maximize the power of the standard library modules
*Where to get third party libraries, and the best practices for utilization
*Creating, packaging, and reusing libraries within and across projects
*Building multi-layered functionality including networks, data, and user interfaces
*Setting up development environments and using virtualenv, pip, and more
Written by veteran Python trainers, the book is structured for easy navigation and logical progression that makes it ideal for individual, classroom, or corporate training.
For Python developers looking to apply their skills to real-world challenges, Python Projects is a goldmine of information and expert insight.
Author(s): Laura Cassell; Alan Gauld
Publisher: Wrox Press
Year: 2014
Language: English
Pages: 384
Python® Projects
ABOUT THE AUTHORS
ABOUT THE TECHNICAL EDITORS
CREDITS
ACKNOWLEDGMENTS
CONTENTS
INTRODUCTION
CHAPTER 1: REVIEWING CORE PYTHON
Exploring the Python Language and the Interpreter
Reviewing the Python Data Types
Numeric Types: Integer and Float
The Boolean Type
The None Type
Collection Types
Strings
Bytes and ByteArrays
Tuples
Lists
Dictionaries
Sets
Using Python Control Structures
Structuring Your Program
Using Sequences, Blocks and Comments
Selecting an Execution Path
Iteration
Handling Exceptions
Managing Context
Getting Data In and Out of Python
Interacting with Users
Using Text Files
Extending Python
Defining and Using Functions
Generator Functions
Lambda Functions
Defining and Using Classes and Objects
Creating and Using Modules and Packages
Using and Creating Modules
Using and Creating Packages
Creating an Example Package
Using Third-Party Packages
Summary
CHAPTER 2: SCRIPTING WITH PYTHON
Accessing the Operating System
Obtaining Information About Users and Their Computer
Obtaining Information About the Current Process
Managing Other Programs
Managing Subprocesses More Effectively
Obtaining Information About Files (and Devices)
Navigating and Manipulating the File system
Plumbing the Directory Tree Depths
Working with Dates and Times
Using the time Module
Introducing the datetime Module
Introducing the calendar Module
Handling Common File Formats
Using Comma-Separated Values
Working with Config Files
Working with XML and HTML Files
Parsing XML Files
Parsing HTML Files
Accessing Native APIs with ctypes and pywin32
Accessing the Operating System Libraries
Using ctypes with Windows
Using ctypes on Linux
Accessing a Windows Application Using COM
Automating Tasks Involving Multiple Applications
Using Python First
Using Operating System Utilities
Using Data Files
Using a Third-Party Module
Interacting with Subprocesses via a CLI
Using Web Services for Server-Based Applications
Using a Native Code API
Using GUI Robotics
Summary
CHAPTER 3: MANAGING DATA
Storing Data Using Python
Using DBM as a Persistent Dictionary
Using Pickle to Store and Retrieve Objects
Accessing Objects with shelve
Analyzing Data with Python
Analyzing Data Using Built-In Features of Python
Analyzing Data with ittertools
Utility Functions
Data Processing Functions
Taming the Vagaries of groupby()
Using itertools to Analyze LendyDB Data
Managing Data Using SQL
Relational Database Concepts
Structured Query Language
Creating Tables
Inserting Data
Reading Data
Modifying Data
Linking Data Across Tables
Digging Deeper into Data Constraints
Revisiting SQLite Field Types
Modeling Relationships with Constraints
Many-to-Many Relationships
Migrating LendyDB to an SQL Database
Accessing SQL from Python
Using SQL Connections
Using a Cursor
Creating the LendyDB SQL Database
Inserting Test Data
Creating a LendyDB API
Exploring Other Data Management Options
Client-Server Databases
NoSQL
The Cloud
Data Analysis with RPy
Summary
CHAPTER 4: BUILDING DESKTOP APPLICATIONS
Structuring Applications
Building Command-Line Interfaces
Building the Data Layer
Building the Core Logic Layer
Building the User Interface
Using the cmd Module to Build a Command-Line Interface
Reading Command-Line Arguments
Jazzing Up the Command-Line Interface with Some Dialogs
Programming GUIs with Tkinter
Introducing Key GUI Principles
Event-Based Programming
GUI Terminology
The Containment Tree
Building a Simple GUI
Building a Tic-Tac-Toe GUI
Sketching a UI Design
Building Menus
Building a Tic-Tac-Toe Board
Connecting the GUI to the Game
Extending Tkinter
Using Tix
Using ttk
Revisiting the Lending Library
Exploring Other GUI Toolkits for Python
wxPython
PyQt
PyGTK
Native GUIs: Cocoa and PyWin32
Dabo
Storing Local Data
Storing Application-Specific Data
Storing User-Selected Preferences
Storing Application State
Logging Error information
Understanding Localization
Using Locales
Using Unicode in Python
Using gettext
Summary
CHAPTER 5: PYTHON ON THE WEB
Python on the Web
Parts of a Web Application
The Client-Server Relationship
Middleware and MVC
HTTP Methods and Headers
What Is an API?
Web Programming with Python
Using the Python HTTP Modules
Creating an HTTP Server
Exploring the Flask Framework
Creating Data Models in Flask
Creating Core Flask Files
More on Python and the Web
Static Site Generators
Web Frameworks
Using Python Across the Wire
XML-RPC
Socket Servers
More Networking Fun in Python
Summary
CHAPTER 6: PYTHON IN BIGGER PROJECTS
Testing with the Doctest Module
Testing with the Unittest Module
Test-Driven Development in Python
Debugging Your Python Code
Handling Exceptions in Python
Working on Larger Python Projects
Releasing Python Packages
Summary
CHAPTER 7: EXPLORING PYTHON’S FRONTIERS
Drawing Pictures with Python
Using Turtle Graphics
Using GUI Canvas Objects
Plotting Data
Using imghdr
Introducing Pillow
Trying Out ImageMagick
Doing Science with Python
Introducing SciPy
Doing Bioscience with Python
Using GIS
Watching Your Language
Getting It All
Playing Games with Python
Enriching the Experience with PyGame
Exploring Other Options
Going to the Movies
The Computer Graphics Kit
Modeling and Animation
Photo Processing
Working with Audio
Integrating with Other Languages
Jython
IronPython
Cython
Tcl/Tk
Getting Physical
Introducing Serial Options
Programming the RaspberryPi
Talking to the Arduino
Exploring Other Options
Building Python
Fixing Bugs
Documenting
Testing
Adding Features
Attending Conferences
Summary
APPENDIX A: ANSWERS TO EXERCISES
Chapter 1 Solutions
Chapter 2 Solutions
Chapter 3 Solutions
Chapter 4 Solutions
Chapter 5 Solutions
Chapter 6 Solutions
Chapter 7 Solutions
APPENDIX B: PYTHON STANDARD MODULES
APPENDIX C: USEFUL PYTHON RESOURCES
Asking Questions: Mailing Lists and More
Reading Blogs
Studying Tutorials and References
Watching Videos
And Now for Something Completely Different…
REFERENCES
INDEX
ADVERT
EULA