Online Book Reader

Home Category

Learning Python - Mark Lutz [0]

By Root 1355 0
Learning Python


Table of Contents

A Note Regarding Supplemental Files

Preface

About This Fourth Edition

Coverage for Both 3.0 and 2.6

New Chapters

Changes to Existing Material

Specific Language Extensions in 2.6 and 3.0

Specific Language Removals in 3.0

About The Third Edition

The Third Edition’s Python Language Changes

The Third Edition’s Python Training Changes

The Third Edition’s Structural Changes

The Third Edition’s Scope Changes

About This Book

This Book’s Prerequisites

This Book’s Scope and Other Books

This Book’s Style and Structure

Book Updates

About the Programs in This Book

Using Code Examples

Font Conventions

Safari® Books Online

How to Contact Us

Acknowledgments

I. Getting Started

1. A Python Q&A Session

Why Do People Use Python?

Software Quality

Developer Productivity

Is Python a “Scripting Language”?

OK, but What’s the Downside?

Who Uses Python Today?

What Can I Do with Python?

Systems Programming

GUIs

Internet Scripting

Component Integration

Database Programming

Rapid Prototyping

Numeric and Scientific Programming

Gaming, Images, Serial Ports, XML, Robots, and More

How Is Python Supported?

What Are Python’s Technical Strengths?

It’s Object-Oriented

It’s Free

It’s Portable

It’s Powerful

It’s Mixable

It’s Easy to Use

It’s Easy to Learn

It’s Named After Monty Python

How Does Python Stack Up to Language X?

Chapter Summary

Test Your Knowledge: Quiz

Test Your Knowledge: Answers

2. How Python Runs Programs

Introducing the Python Interpreter

Program Execution

The Programmer’s View

Python’s View

Execution Model Variations

Python Implementation Alternatives

Execution Optimization Tools

Frozen Binaries

Other Execution Options

Future Possibilities?

Chapter Summary

Test Your Knowledge: Quiz

Test Your Knowledge: Answers

3. How You Run Programs

The Interactive Prompt

Running Code Interactively

Why the Interactive Prompt?

Using the Interactive Prompt

System Command Lines and Files

A First Script

Running Files with Command Lines

Using Command Lines and Files

Unix Executable Scripts (#!)

Clicking File Icons

Clicking Icons on Windows

The input Trick

Other Icon-Click Limitations

Module Imports and Reloads

The Grander Module Story: Attributes

import and reload Usage Notes

Using exec to Run Module Files

The IDLE User Interface

IDLE Basics

Using IDLE

Advanced IDLE Tools

Other IDEs

Other Launch Options

Embedding Calls

Frozen Binary Executables

Text Editor Launch Options

Still Other Launch Options

Future Possibilities?

Which Option Should I Use?

Chapter Summary

Test Your Knowledge: Quiz

Test Your Knowledge: Answers

Test Your Knowledge: Part I Exercises

II. Types and Operations

4. Introducing Python Object Types

Why Use Built-in Types?

Python’s Core Data Types

Numbers

Strings

Sequence Operations

Immutability

Type-Specific Methods

Getting Help

Other Ways to Code Strings

Pattern Matching

Lists

Sequence Operations

Type-Specific Operations

Bounds Checking

Nesting

Comprehensions

Dictionaries

Mapping Operations

Nesting Revisited

Sorting Keys: for Loops

Iteration and Optimization

Missing Keys: if Tests

Tuples

Why Tuples?

Files

Other File-Like Tools

Other Core Types

How to Break Your Code’s Flexibility

User-Defined Classes

And Everything Else

Chapter Summary

Test Your Knowledge: Quiz

Test Your Knowledge: Answers

5. Numeric Types

Numeric Type Basics

Numeric Literals

Built-in Numeric Tools

Python Expression Operators

Numbers in Action

Variables and Basic Expressions

Numeric Display Formats

Comparisons: Normal and Chained

Division: Classic, Floor, and True

Integer Precision

Complex Numbers

Hexadecimal, Octal, and Binary Notation

Bitwise Operations

Other Built-in Numeric Tools

Other Numeric Types

Decimal Type

Fraction Type

Sets

Booleans

Numeric Extensions

Chapter Summary

Test Your Knowledge: Quiz

Test Your Knowledge: Answers

6. The Dynamic Typing Interlude

The Case of the Missing Declaration Statements

Variables, Objects,

Return Main Page Next Page

®Online Book Reader