1. Trang chủ
  2. » Tất cả

Python.Pocket.Reference.4th.Edition.Mark.Lutz.2009

210 48 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Cấu trúc

  • Python Pocket Reference 4 Edition (10-2009) (Elements-ATTiCA)

  • Table of Contents

  • Introduction

  • Conventions

  • Using Code Examples

  • Command-Line Options

    • Python Options

    • Program Specification

  • Environment Variables

    • Operational Variables

    • Command-Line Option Variables

  • Built-in Types and Operators

    • Operators and Precedence

    • Operator Usage Notes

    • Operations by Category

    • Sequence Operation Notes

      • Indexing: S[i]

      • Slicing: S[i:j]

      • Slicing: S[i:j:k]

      • Other

  • Specific Built-in Types

    • Numbers

      • Literals and creation

      • Operations

      • Decimal and fraction

      • Other numeric types

    • Strings

      • Literals and creation

      • Operations

      • String formatting

      • String formatting expression

      • String formatting method

      • Template string substitution

      • String methods

      • byte and bytearray methods

      • Searching

      • Splitting and joining

      • Formatting

      • Content tests

      • The original string module

    • Unicode Strings

      • Unicode support in Python 3.0

      • byte and bytearray strings

      • Unicode support in Python 2.X

    • Lists

      • Literals and creation

      • Operations

      • List comprehension expressions

      • Generator expressions

      • Other generators and comprehensions

    • Dictionaries

      • Literals and creation

      • Operations

    • Tuples

      • Literals

      • Operations

    • Files

      • Input files

      • Output files

      • Any files

      • Attributes (all read-only)

      • File context managers

      • Notes

    • Sets

      • Literals and creation

      • Operations

    • Other Common Types

      • Boolean

    • Type Conversions

  • Statements and Syntax

    • Syntax Rules

    • Name Rules

      • Name format

      • Name conventions

  • Specific Statements

    • The Assignment Statement

      • Augmented assignment

      • Normal and extended sequence assignment

    • The Expression Statement

      • Call syntax

      • Arbitrary arguments call syntax

    • The print Statement

      • Python 2.X print statements

    • The if Statement

    • The while Statement

    • The for Statement

    • The pass Statement

    • The break Statement

    • The continue Statement

    • The del Statement

    • The def Statement

      • Python 3.0 keyword-only arguments

      • Python 3.0 function annotations

      • lambda expressions

      • Defaults and attributes

      • Function and method decorators

    • The return Statement

    • The yield Statement

      • Generators and iterators

    • The global Statement

    • The nonlocal Statement

    • The import Statement

      • Package imports

    • The from Statement

      • Package relative import syntax

    • The class Statement

      • Class decorators in Python 2.6 and 3.0

      • Metaclasses

    • The try Statement

      • Python 2.X try statement forms

    • The raise Statement

      • Class exceptions

      • Python 2.X raise statement forms

    • The assert Statement

    • The with Statement

      • Multiple context managers in Python 3.1

    • Python 2.X Statements

  • Namespace and Scope Rules

    • Qualified Names: Object Namespaces

    • Unqualified Names: Lexical Scopes

    • Statically Nested Scopes

  • Object-Oriented Programming

    • Classes and Instances

      • Class objects provide default behavior

      • Instance objects are generated from classes

      • Inheritance rules

    • Pseudoprivate Attributes

      • Module privates

      • Class privates

    • New Style Classes

  • Operator Overloading Methods

    • For All Types

    • For Collections (Sequences, Mappings)

    • For Numbers (Binary Operators)

      • Basic binary methods

      • Right-side binary methods

      • Augmented binary methods

    • For Numbers (Other Operations)

    • For Descriptors

    • For Context Managers

    • Python 2.X Operator Overloading Methods

      • Methods in Python 3.0 only

      • Methods in Python 2.X only

  • Built-in Functions

    • Python 2.X Built-in Functions

      • Python 3.0 built-ins not supported by Python 2.6

      • Python 2.6 built-ins not supported by Python 3.0

  • Built-in Exceptions

    • Superclasses (Categories)

    • Specific Exceptions Raised

    • Warning Category Exceptions

    • Warnings Framework

    • Python 2.X Built-in Exceptions

  • Built-in Attributes

  • Standard Library Modules

  • The sys Module

  • The string Module

    • Module Functions and Classes

    • Constants

  • The os System Module

    • Administrative Tools

    • Portability Constants

    • Shell Commands

    • Environment Tools

    • File Descriptor Tools

    • File Pathname Tools

    • Process Control

    • The os.path Module

  • The re Pattern-Matching Module

    • Module Functions

    • Regular Expression Objects

    • Match Objects

    • Pattern Syntax

  • Object Persistence Modules

    • dbm and shelve Modules

    • pickle Module

      • Pickling interfaces

      • Unpickling interfaces

      • Usage notes

  • The tkinter GUI Module and Tools

    • tkinter Example

    • tkinter Core Widgets

    • Common Dialog Calls

      • Module tkinter.messagebox (tkMessageBox in Python 2.X)

      • Module tkinter.simpledialog (tkSimpleDialog in Python 2.X)

      • Module tkinter.colorchooser (tkColorChooser in Python 2.X)

      • Module tkinter.filedialog (tkFileDialog in Python 2.X)

    • Additional tkinter Classes and Tools

    • Tcl/Tk-to-Python/tkinter Mappings

  • Internet Modules and Tools

    • Commonly Used Library Modules

  • Other Standard Library Modules

    • The math Module

    • The time Module

    • The datetime Module

    • Threading Modules

    • Binary Data Parsing

  • Python Portable SQL Database API

    • API Usage Example

    • Module Interface

    • Connection Objects

    • Cursor Objects

    • Type Objects and Constructors

  • Python Idioms and Hints

    • Core Language Hints

    • Environment Hints

    • Usage Hints

    • Assorted Hints

  • Index

Nội dung

Python Pocket Reference FOURTH EDITION Python Pocket Reference Mark Lutz Beijing • Cambridge • Farnham • Kưln • Sebastopol • Taipei • Tokyo Python Pocket Reference, Fourth Edition by Mark Lutz Copyright © 2010 Mark Lutz All rights reserved Printed in Canada Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472 O’Reilly books may be purchased for educational, business, or sales promotional use Online editions are also available for most titles (http://my.safari booksonline.com) For more information, contact our corporate/institutional sales department: (800) 998-9938 or corporate@oreilly.com Editor: Julie Steele Production Editor: Sumita Mukherji Proofreader: Kiel Van Horn Indexer: John Bickelhaupt Cover Designer: Karen Montgomery Interior Designer: David Futato Printing History: October 1998: January 2002: February 2005: October 2009: First Edition Second Edition Third Edition Fourth Edition Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc The Pocket Reference series designations, Python Pocket Reference, the image of a rock python, and related trade dress are trademarks of O’Reilly Media, Inc Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a trademark claim, the designations have been printed in caps or initial caps While every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein ISBN: 978-0-596-15808-8 [TM] 1253806016 Contents Python Pocket Reference Introduction Conventions Command-Line Options Python Options Program Specification Environment Variables Operational Variables Command-Line Option Variables Built-in Types and Operators Operators and Precedence Operator Usage Notes Operations by Category Sequence Operation Notes Specific Built-in Types Numbers Strings Unicode Strings Lists Dictionaries Tuples Files 1 4 7 8 10 11 15 16 16 19 33 36 41 44 45 v Sets Other Common Types Type Conversions Statements and Syntax Syntax Rules Name Rules Specific Statements The Assignment Statement The Expression Statement The print Statement The if Statement The while Statement The for Statement The pass Statement The break Statement The continue Statement The del Statement The def Statement The return Statement The yield Statement The global Statement The nonlocal Statement The import Statement The from Statement The class Statement The try Statement The raise Statement The assert Statement The with Statement Python 2.X Statements Namespace and Scope Rules Qualified Names: Object Namespaces vi | Table of Contents 49 51 52 53 53 54 56 57 59 60 62 62 63 63 63 64 64 64 68 68 70 70 71 72 73 75 78 80 80 82 82 83 Unqualified Names: Lexical Scopes Statically Nested Scopes Object-Oriented Programming Classes and Instances Pseudoprivate Attributes New Style Classes Operator Overloading Methods For All Types For Collections (Sequences, Mappings) For Numbers (Binary Operators) For Numbers (Other Operations) For Descriptors For Context Managers Python 2.X Operator Overloading Methods Built-in Functions Python 2.X Built-in Functions Built-in Exceptions Superclasses (Categories) Specific Exceptions Raised Warning Category Exceptions Warnings Framework Python 2.X Built-in Exceptions Built-in Attributes Standard Library Modules The sys Module The string Module Module Functions and Classes Constants The os System Module Administrative Tools Portability Constants Shell Commands 83 84 85 85 86 87 88 88 93 94 97 98 99 99 102 119 124 124 125 129 130 131 131 132 133 139 139 140 141 141 142 143 Table of Contents | vii Environment Tools File Descriptor Tools File Pathname Tools Process Control The os.path Module The re Pattern-Matching Module Module Functions Regular Expression Objects Match Objects Pattern Syntax Object Persistence Modules dbm and shelve Modules pickle Module The tkinter GUI Module and Tools tkinter Example tkinter Core Widgets Common Dialog Calls Additional tkinter Classes and Tools Tcl/Tk-to-Python/tkinter Mappings Internet Modules and Tools Commonly Used Library Modules Other Standard Library Modules The math Module The time Module The datetime Module Threading Modules Binary Data Parsing Python Portable SQL Database API API Usage Example Module Interface Connection Objects Cursor Objects viii | Table of Contents 144 145 147 150 153 155 155 157 158 159 163 164 166 168 168 169 170 171 171 173 173 175 176 176 177 177 178 179 179 180 181 181 Type Objects and Constructors Python Idioms and Hints Core Language Hints Environment Hints Usage Hints Assorted Hints Index 182 183 183 184 185 187 189 Table of Contents | ix

Ngày đăng: 13/04/2019, 01:45