1 option
Python cookbook
- Format:
- Book
- Author/Creator:
- Martelli, Alex, author.
- Language:
- English
- Subjects (All):
- Python (Computer program language).
- Physical Description:
- 1 online resource (xxix, 574 p. ; )
- Edition:
- 1st edition
- Place of Publication:
- [Place of publication not identified] O'Reilly 2002
- Language Note:
- English
- System Details:
- text file
- Summary:
- The Python Cookbook is a collection of problems, solutions, and practical examples for Python programmers, written by Python programmers. Over the past year, members of the Python community have contributed material to an online repository of Python recipes hosted by ActiveState. This book contains the best of those recipes, accompanied by overviews and background material by key Python figures. The recipes in the Python Cookbook range from simple tasks, such as working with dictionaries and list comprehensions, to entire modules that demonstrate templating systems and network monitoring. This book contains over 200 recipes on the following topics: Searching and sorting Manipulating text Working with files and the filesystem Object-oriented programming Dealing with threads and processes System administration Interacting with databases Creating user interfaces Network and web programming Processing XML Distributed programming Debugging and testing Extending Python This book is a treasure trove of useful code for all Python programmers, from novices to advanced practitioners, with contributions from such Python luminaries as Guido Van Rossum, David Ascher, Tim Peters, Paul Prescod, Mark Hammond, and Alex Martelli, as well as over 100 other Python programmers. The recipes highlight Python best practices and can be used directly in day-to-day programming tasks, as a source of ideas, or as a way to learn more about Python. The recipes in the Python Cookbook were edited by David Ascher, who is on the board of the Python Software Foundation and is the co-author of Learning Python, and Alex Martelli, who is known for his numerous and exhaustive postings on the Python mailing list. The book contains a foreword by Guido van Rossum, the creator of Python.
- Contents:
- Intro
- Table of Contents
- Preface
- The Design of the Book
- The Implementation of the Book
- Using the Code from This Book
- Audience
- Organization
- Further Reading
- Conventions Used in This Book
- How to Contact Us
- Safari® Enabled
- Acknowledgments
- David Ascher
- Alex Martelli
- Anna Martelli Ravenscroft
- Text
- 1.0 Introduction
- What Is Text?
- Basic Textual Operations
- Sources of Text
- String Basics
- 1.1 Processing a String One Character at a Time
- Problem
- Solution
- Discussion
- See Also
- 1.2 Converting Between Characters and Numeric Codes
- 1.3 Testing Whether an Object Is String-like
- 1.4 Aligning Strings
- 1.5 Trimming Space from the Ends of a String
- 1.6 Combining Strings
- 1.7 Reversing a String by Words or Characters
- 1.8 Checking Whether a String Contains a Set of Characters
- 1.9 Simplifying Usage of Strings' translate Method
- 1.10 Filtering a String for a Set of Characters
- 1.11 Checking Whether a String Is Text or Binary
- 1.12 Controlling Case
- 1.13 Accessing Substrings
- 1.14 Changing the Indentation of a Multiline String
- 1.15 Expanding and Compressing Tabs
- See Also.
- 1.16 Interpolating Variables in a String
- 1.17 Interpolating Variables in a String in Python 2.4
- 1.18 Replacing Multiple Patterns in a Single Pass
- 1.19 Checking a String for Any of Multiple Endings
- 1.20 Handling International Text with Unicode
- 1.21 Converting Between Unicode and Plain Strings
- 1.22 Printing Unicode Characters to Standard Output
- 1.23 Encoding Unicode Data for XML and HTML
- 1.24 Making Some Strings Case-Insensitive
- 1.25 Converting HTML Documents to Text on a Unix Terminal
- Files
- 2.0 Introduction
- File Basics
- Portability and Flexibility
- 2.1 Reading from a File
- 2.2 Writing to a File
- 2.3 Searching and Replacing Text in a File
- 2.4 Reading a Specific Line from a File
- 2.5 Counting Lines in a File
- 2.6 Processing Every Word in a File
- 2.7 Using Random-Access Input/Output
- 2.8 Updating a Random-Access File
- 2.9 Reading Data from zip Files
- 2.10 Handling a zip File Inside a String
- 2.11 Archiving a Tree of Files into a Compressed tar File
- 2.12 Sending Binary Data to Standard Output Under Windows
- 2.13 Using a C++-like iostream Syntax
- 2.14 Rewinding an Input File to the Beginning
- 2.15 Adapting a File-like Object to a True File Object
- 2.16 Walking Directory Trees
- 2.17 Swapping One File Extension for Another Throughout a Directory Tree
- 2.18 Finding a File Given a Search Path
- 2.19 Finding Files Given a Search Path and a Pattern
- 2.20 Finding a File on the Python Search Path
- 2.21 Dynamically Changing the Python Search Path
- 2.22 Computing the Relative Path from One Directory to Another
- 2.23 Reading an Unbuffered Character in a Cross-Platform Way
- 2.24 Counting Pages of PDF Documents on Mac OS X
- 2.25 Changing File Attributes on Windows
- 2.26 Extracting Text from OpenOffice.org Documents
- 2.27 Extracting Text from Microsoft Word Documents
- 2.28 File Locking Using a Cross-Platform API.
- Problem
- 2.29 Versioning Filenames
- 2.30 Calculating CRC-64 Cyclic Redundancy Checks
- Time and Money
- 3.0 Introduction
- The time Module
- Time and Date Objects
- Decimal
- 3.1 Calculating Yesterday and Tomorrow
- 3.2 Finding Last Friday
- 3.3 Calculating Time Periods in a Date Range
- 3.4 Summing Durations of Songs
- 3.5 Calculating the Number of Weekdays Between Two Dates
- 3.6 Looking up Holidays Automatically
- 3.7 Fuzzy Parsing of Dates
- 3.8 Checking Whether Daylight Saving Time Is Currently in Effect
- 3.9 Converting Time Zones
- 3.10 Running a Command Repeatedly
- 3.11 Scheduling Commands
- 3.12 Doing Decimal Arithmetic
- 3.13 Formatting Decimals as Currency
- 3.14 Using Python as a Simple Adding Machine
- 3.15 Checking a Credit Card Checksum
- 3.16 Watching Foreign Exchange Rates
- Python Shortcuts
- 4.0 Introduction
- 4.1 Copying an Object
- 4.2 Constructing Lists with List Comprehensions
- 4.3 Returning an Element of a List If It Exists
- 4.4 Looping over Items and Their Indices in a Sequence
- 4.5 Creating Lists of Lists Without Sharing References
- 4.6 Flattening a Nested Sequence
- 4.7 Removing or Reordering Columns in a List of Rows
- 4.8 Transposing Two-Dimensional Arrays
- 4.9 Getting a Value from a Dictionary
- 4.10 Adding an Entry to a Dictionary
- 4.11 Building a Dictionary Without Excessive Quoting
- 4.12 Building a Dict from a List of Alternating Keys and Values
- 4.13 Extracting a Subset of a Dictionary
- 4.14 Inverting a Dictionary
- 4.15 Associating Multiple Values with Each Key in a Dictionary
- 4.16 Using a Dictionary to Dispatch Methods or Functions
- 4.17 Finding Unions and Intersections of Dictionaries
- 4.18 Collecting a Bunch of Named Items
- 4.19 Assigning and Testing with One Statement
- 4.20 Using printf in Python
- 4.21 Randomly Picking Items with Given Probabilities.
- Notes:
- Bibliographic Level Mode of Issuance: Monograph
- Description based on publisher supplied metadata and other sources.
- OCLC:
- 774401183
The Penn Libraries is committed to describing library materials using current, accurate, and responsible language. If you discover outdated or inaccurate language, please fill out this feedback form to report it and suggest alternative language.