Second Edition August 2006
ISBN 978-0-596-10046-9
Weitere Informationen zu diesem Buch
Inhaltsverzeichnis |
Index |
Probekapitel |
Rezensionen |
Index
[ Numbers ], [ Symbols ], [ A ], [ B ], [ C ], [ D ], [ E ], [ F ], [ G ], [ H ], [ I ], [ J ], [ K ], [ L ], [ M ], [ N ], [ O ], [ P ], [ Q ], [ R ], [ S ], [ T ], [ U ], [ V ], [ W ], [ X ], [ Y ], [ Z ], Chapter 28 28
Symbols[ Top ]
See also
complete list of operators, Table 4-2, 50
regular expression pattern syntax, Table 9-2, 201-202
string-formatting specifier syntax, 193-194
& (ampersand), set intersection operator, 59
<> (angle brackets)
Tkinter event names, 447
obsolete form of !=, 50
* (asterisk)
from statement, 143
sequence repetition operator, 54
special form in def parameters, 72
special form in function call, 75
@ (at-sign), decorators, 37, 115-116
` (backquote), string conversion, 50
\ (backslash)
in directory paths, 24
escape sequences in string literals, 42
joining physical lines into one logical line, 34
in regular expressions, 202
^ (caret), set symmetric difference operator, 59
: (colon)
compound statements, 38
dictionary literals, 44
, (comma)
class statement, 82-83
def statement, 70
function call, 74
tuples, 42
{} (curly braces), dictionary literals, 44
$ (dollar sign), in template strings, 196
** (double asterisk)
exponentiation operator, 53
special form in def parameters, 72
special form in function call, 75
== (double equals), equality comparison, 53
// (double forward slash), truncating division operator, 52-53
" (double quote), string literals, 40-41
_ _ (double underscore)
class-private variables, 85
special methods, 82, 104
. . . (ellipsis)
in array slicing, 382-383
in doctest tracebacks, 456
prompt in interactive sessions, 25
= (equals)
assignment, 47
augmented assignment, 36, 49
in long-form option strings, 180
named arguments, 44, 74-75
optional parameters, 71
! (exclamation point), pdb command, 467
/ (forward slash)
in directory paths, 24
semantics of division, 24, 52-53
- (hyphen)
command-line options, 23-24, 179
set difference operator, 59
() (parentheses)
class statement, 82
def statement, 70
function call, 74
genexps, 79-80
ternary operator, 51
tuples, 42
% (percent sign)
remainder operator, 52
string formatting, 193
. (period)
attribute syntax, 46, 84, 87, 89-91
in docstrings, 73
in floating-point literals, 39
+ (plus sign)
to form complex numbers, 40
sequence concatenation operator, 53
# (pound sign)
comments, 33
coding directive, 35
shebang line, 29
; (semicolon)
not needed at end of line, 34
separator for multistatement lines, 24, 37-38
' (single quote), string literals, 40
[] (square brackets)
indexing, 54, 60, 380
list comprehensions, 67
list literals, 43
slicing, 55, 381-383
""" (triple double quote), string literals, 40-41
>>> (triple right-angle bracket)
prompt in interactive sessions, 25
recognized by doctest, 454-455
''' (triple single quote), string literals, 40-41
_ (underscore)
class-private variables, 85
in gettext (i18n), 274
in interactive sessions, 25
module-private variables, 142
| (vertical bar), set union operator, 59
A[ Top ]
Active Server Pages (ASP), 557
ActivePython, 19
ActiveState
Python Cookbook, 11
Python IDEs offered by, 27
anydbm module, 286
Apache servers
installing Python CGI scripts, 552
Webware/mod_webkit for, 559
Apple Macintosh (see Macintosh)
applets, Jython, 6, 664
applications
developing, 474
event-driven, 406, 533
multithreaded, 350
Windows, with COM, 676
arguments (when calling functions), 73-75
arithmetic operators, 52-53, 112-115, 369-370
ArithmeticError exception, 129
ARPA module, 327
array module, 375
array objects (Numeric module), 378
attributes and methods, 388-390
comparisons, 384-385
factory functions, 385-388
indexing and slicing, 381-384
operations, 390-392
type codes, 379-380
ascii, default encoding in Python, 199-200
character to code ordinal (ord), 166
code ordinal to character (chr), 161
ASP (Active Server Pages), 557
assert statement, 138
AssertionError class (built-in), assert statement, 138
assignment statements
assignment, 47
augmented assignment, 36, 49
in long-form option strings, 180
named arguments, 44, 74
to Numeric.array slices, 383
asynchat module, 537
performance characteristics, 558
asynchronous programming, 533
asyncore module, 535
performance characteristics, 558
atexit module, 337
atomic operations, 341, 344
Attr class (minidom module), 602
AttributeError exception, 90
AttributeList class (minidom module), 600
attributes
binding, 84-87
of class objects, 84
deleting, 98
of module objects, 140
overriding, 95
unbinding, 84, 87
attributes attribute (Node object), 600
Attributes object (xml.sax package), 595
augmented assignment statements, 49
authentication
SMTP servers, 505
URL access to network protocols, 502
B[ Top ]
bag (see defaultdict type)
base classes, 82-83
base64 module, 561
BaseHTTPServer module, 530
web server implementation, 558
BaseRequestHandler class (SocketServer module), 528
basestring type, 154
benchmarking, 451, 475
Berkeley Database library (see BSD DB)
big-O notation and concepts, 476-479
binaries, downloading and installing, 18-19
binary data, encoding as text, 561-563
binary files, 219-220
Binary Large OBjects (see BLOBs)
binary search, 176
binding variables, 46
bisect module, 176
BitmapImage class, 414
blank lines, ignored, 33-34
BLOBs (Binary Large OBjects), 294-295
blocks, indentation and, 34
bool type, 154
Boolean values, 45
Boost Python Library, 645
bound methods, 91
break statement, 68
browsers, 575
BSD DB (Berkeley Database library), 287, 289
bsddb module, 288-290
buffer type, 154
buffering, cmd.py and, 357
buffers, file objects, 218
building a list (see list comprehensions)
building a string from pieces, 484
built-in exception classes, 129-132
built-in functions, 158-167
built-in modules, 141
_ _import_ _ function, 147
loading, 144
built-in types, 155-159
inheriting from, 83, 98, 103-104
built-in variable _ _debug_ _, 138
Button class (Tkinter module), 415
flash method, 415
bz2 module, 232
C[ Top ]
C compiler, ISO-compliant, installing Python and, 14
C library, time module and, 302
C programming language, CPython and, 614-646
C++ programming language, extending Python with, 645-646
calculator, 25
calendar module, 317-318
call stack, unwinding on exceptions, 126
callables, 45
calling functions, 73-74
Canvas class (Tkinter module), 436-442
case sensitivity, Windows os.environ keys, 354
cdef (in Pyrex), 651-652
CGI (Common Gateway Interface), 545
cgi module, 545-552
CGI scripting, 545
Content-Type header, 549
cookies, 553
error messages, 550
HTML forms submission, 546
output, 549
scripts, 551, 557
CGIHTTPServer module, 530
cgitb module, 551
character sets, 34
Checkbutton class (Tkinter module), 415
Cheetah package, 586
CherryPy, 559
child widgets, 420
childNodes attribute (Node object), 600
circular imports, 146
class body, 83-85
class methods, 99
class object, 84-85
class statement, 82
classes, 82-85
bound and unbound methods, 91-94
descriptors, 82, 85-86
inheritance, 94-98
metaclasses, 116-120
new-style, 81, 83, 103-104, 117-118
old-style (classic), 81, 103, 117
Classic Python (see Python)
class-level methods, 99
classmethod type, 99, 154
class-private variables, 85
clauses in compound statements, 38
CLDR (Common Locale Data Repository), 276
clients, networking, 493
closure (see nested functions)
cmath module, 365
cmd module, 265-268
code object, 329-332
codecs module, 198-199
CodeWarrier Pro 7 C compiler, 18
coercion (see conversions)
collections module, 173-175
COM, extending Python with, 646
command-line options, 23-24, 179
comments, 33
Common Locale Data Repository (CLDR), 278
comparing arrays of numbers, 384
comparing directories, 251-252
comparison operators, 51, 53
special methods, 104-106
and unit tests, 460
compiling
to bytecode, 28, 145
to code objects, 160, 329
to EXE or .app files, 675-676
to Java bytecode, 662-664
complex numbers, 40
complex type, 154
compound statements, 38
compressed files
bz2 module, 232
gzip module, 230-232
tarfile module, 233-235
zipfile module, 235-239
zlib module, 239
concatenating many strings into one, 484
concatenation, sequences, 54
Condition class (threading module), 344, 347
conditional operator (see ternary operator)
config method, Widget object, 411
Connection object (DBAPI-compliant modules), 296
console I/O, 260-265
Console module, 265
constants (see literals)
constructing a list (see list comprehensions)
constructing a string from parts, 484
constructor, 86
constructor function, copy_reg module, 283
container widgets, 420
containers, special methods for, 109-110
(see also collections module)
ContentHandler class (xml.sax package), 594-595
continue statement, 68
control flow statements, 62-69
conversions
numeric operators, 52
sequences, 54
converting
numbers, 155
strings, 198
cookies, 553
Cooledit program, 27
Coordinated Universal Time (UTC), 302
copy module, 172
copy_reg module, pickling customization with, 283
cPickle module, 279-281
CPython (Classic Python), 5, 613
C-coded Python extensions, 614-627, 633, 638
CNRI Open Source GPL-Compatible License, 7
embedding, 647-653
extending, 614, 645
installing, 14
reference counts, 333
CRC checksums, 239
cross-platform portability, 5
cStringIO module, 229
ctypes, 646
currying, 175
curses package, 261
Cursor object (DBAPI), 297-298
custom exceptions, 133
custom metaclasses, 116-119
customization, site and user, 338
cyclic garbage loops, 333
Cygwin, building Python for, 17
D[ Top ]
data types
Boolean values, 45
callables, 45
C-coded, 638
dictionaries, 44
None, 45
numbers, 38
complex, 40
floating-point, 39
integers, 39
sequences
iterables, 40
lists, 43
strings, 40-42
tuples, 42
sets, 43
user-definable, 81
Database API (see DBAPI)
date/time values, 302-316
computing moveable feast days, 327
in ISO 8601 formats, 327
time-tuple, 302
datetime class, datetime module, 309
DateTime class (mx.DateTime module), 319-323
datetime module, 306
DateTimeDelta class (mx.DateTime module), 324-326
dateutil module, 313-315
date class, datetime module, 306
DB2 module, 299
DBAPI (Database API) 2.0, 277, 292-299
dbhash module, 286-287
dbm library, 285
dbm module, 287
DBM modules, 285
anydbm module, 286
bsddb module, 288
dbm/gdbm/dbhash modules, 287
dumbdbm module, 287
whichdb module, 287
DCOracle2 module, 299
debugging, 451, 461
CGI scripts, 531
HTML, 581
in IDLE, 470
inspect module, 462
pdb module, 466
race conditions, 351
traceback module, 466
warnings module, 471
decimal integer literals, 39
decimal module, 372
declarations
cdef (in Pyrex), 651-652
no such thing in Python, 37, 46
decorators, 115
deep copies, 172-173
def statement, 70, 85
default encoding (Unicode), 169, 170, 298, 338-339
defaultdict type (collections module), 174-175
defining
functions, 70
in class body, 85
metaclasses, 118
del statement, 49
delimiters, 35, 36
deque type (collections module), 173-174
descendants, 83
description attribute, 297
descriptors, 85
destructor, 105
development environments, 26
text editors with Python support, 27
dict type, 154
dictionaries, 44
exec statement and, 328
indexing, 60
membership checking, 60
methods, 60
optimizing operations on, 479
DictionaryType attribute (types module), 332
DictType attribute (types module), 332
dircmp class, 251
directories (see filesystem operations)
directory paths, distribution utilities, 667
dispatcher class (asyncore module), 535-536
distributed computing, 516-519
distribution root directory, 667
setup.py script, 667
distribution utilities (see distutils)
distributions, 667
root directory of, 667
distutils (distribution utilities), 150, 666
creating prebuilt distributions, 674
distribution contents, 669
distribution root directory, 666
distutils module, setup function, 667
distutils package, 151
providing metadata about distribution, 667
setup.cfg file, 673
setup.py script, 667
division operators, 52
Django, 559
DLLs (dynamic load libraries), 613
interoperability of Python release and debugging builds, 16
DNS (Domain Name System), 521
docstrings (documentation strings), 72, 85, 142
doctest module, 454
Document class (minidom module), 602-607
Document Object Model (see DOM)
Document Type Definition (DTD), 593
documentation, 10
embedding/extending Python, 613
documentation strings (see docstrings)
DOM (Document Object Model), parsing XML, 599
minidom module, 599
pulldom module, 605
xml.dom package, 599
Domain Name System (DNS), 521
DOMException class (xml.dom package), 599
double-ended queue (see deque type)
DTD (Document Type Definition), 593
dumbdbm module, 286-287
dynamic execution, 328
dynamic load libraries (see DLLs)
E[ Top ]
EAFP (easier to ask forgiveness than permission), 134
Queue module and, 343
echo servers
TCP, 525
UDP, 527
eGenix GmbH, 306, 319
Element class (minidom module), 603-607
ElementTree, 592, 599, 607
ellipsis ( . . . )
in array slicing, 382-383
in doctest tracebacks, 456
prompt in interactive sessions, 25
else clause, loop statements, 69
emacs program, 27
email package, 564
Encoders module, 570
functions, 564
Generator module, 568
Utils module, 570
email protocols, 503
poplib module, 503
smtplib module, 505
embedding/extending
CPython, 613
Jython, 655
Encoders module, 570
encoding attribute, 219
encoding binary data as text, 561
base64 module, 561
quopri module, 562
uu module, 563
encodings
codecs, 198
default (see default encoding)
Latin-1, 582
network, 561
encodings package, 199
entity references, HTML, 582
Entry class (Tkinter module), 416
enumerate type, 155
environ attribute (os module), 354
environment variables
process environment, 353
Python interpreter and, 22
EOFError exception, 165
epoch, 302
equality and inequality, 50, 53
and hashing, 107
identity, 162
special methods, 104-106
and unit tests, 460
errno module, 240
error handling, 134-138
error messages, 471
CGI scripting, 550
file printed to, 127
traceback messages, 121
escape sequences, strings, 41
etree (see ElementTree)
Event class
threading module, 344
Tkinter module, 446
event scheduler, 316
event-driven applications
GUI applications, 406
network programs, 533
events, 540
binding callbacks to, 446
Exception class (built-in), 129
exception classes
custom, 132
DBAPI, 293
standard, 130
exception handling, 121
exception propagation, 126
Python 2.5, 124
try statement, 121-123
exceptions, 121
C-coded Python extensions, 625
custom, 133
exception objects, 129-132
OSError, 240
pending, gathering information about, 133
raise statement, 128
standard, hierarchy of, 129
exec statement, 328
limiting use of, 328, 486
executables, creating, 674-676
execution, 145
dynamic, 328
exponentiation operators, 53
ternary exponentiation-and-modulo, 165, 115
expression statements, 329
expressions, 37, 50
exec statement and, 329
eXtensible Markup Language (see XML)
extension modules, 5, 153
C-coded, 615
portability and, 5
Python implementations and, 7
resources for further information, 11
writing in lower-level languages, 5
F[ Top ]
False, 45
factory functions, 88
FastCGI, 557
Feasts module, 327
FFT (Fast Fourier Transform), 403
FieldStorage class (cgi module), 547-548
FIFO (first-in first-out) queue (see deque type)
file descriptor operations, 253-256
file extensions, order of, when searching filesystem for modules, 145
file objects, 155, 216-221
file-like objects, polymorphism, 222
memory-mapped, 360
tempfile module, 223-224
filecmp module, 250-252
fileinput module, 224-226
files
compressed, 15
bz2 module, 232
gzip module, 230-232
tarfile module, 233-235
zipfile module, 235-239
zlib module, 239
HTML, getting information from, 576
_ _init_ _.py, 667
.jar, Jython and, 6
jython.jar, 657
permissions, 242
.pythonrc.py, 339
site.py, 338
filesystem operations, 241-256
filesystems, searching for modules, 144
filling text, 197
filters, warnings module, 472
flags argument (compile function), 205
float type, 155
floating-point numbers, 39
generating pseudorandom, 372
in string formats, 195
mathematical functions on, 365
Font class (tkFont module), 433
for statement, 64-68
else clause, 69
formatter module, 581
formatting strings, 193-195
Fortran, extending Python, 645
Frame class (Tkinter module), 420
from statement
avoiding from...import, 486
importing modules from packages, 149
module object, 142
frozenset type, 155
FTP class (ftplib module), 506-509
ftplib module, 493, 507
functional module, 175
functions, 70-80
built-in, 158-167
calling and argument passing, 73-74
C-coded Python extension modules, 617
classes with callable instances, 93-94, 105
defining, 70, 85
function objects, 72-73, 332
generators, 78-80
lambda expressions, 78
nested, 77
parameters, 71-72
recursion, 80
_ _future_ _, importing, 36, 53
G[ Top ]
gadfly module, 299
garbage collection
getrefcount function (module sys), 169
reference counting (C extensions), 620
(see also gc module)
gc module, 333
disable function, 335
garbage attribute, 334
gdbm module, 287
generator expressions (genexps), 79-80
Generator module (email package), 568
generators
functions, 78-80
generator objects, Python 2.5, 126
genexps (generator expressions), 79-80
getpass module, 258
gettext module, 274-276
GIF (Graphical Interchange Format), 414
GIL (global interpreter lock), 341
global statement, 76
global variables, thread synchronization and, 346
gmpy module, 373-374
GMT (Greenwich Mean Time), retrieving current, 320
GNU, 258
GNU Public License (GPL), 8
GNU Readline Library, 258
GPL (GNU Public License), 8
Graphical Interchange Format (GIF), 414
graphical user interfaces (see GUIs)
Greenwich Mean Time (GMT), retrieving current, 320
Gregorian calendar, 319
GUIs (graphical user interfaces), 405-450
other GUI toolkits, 405
Tkinter package, 405-450
gzip module, 230-232
H[ Top ]
hashing, 43-44, 107, 162
headers, clauses, 38
heapq module, 177
hierarchy of standard exceptions, 129
HTML (HyperText Markup Language), 575-590
forms and CGI scripting, 546
generating, 586-590
getting information from (parsing), 575-585
htmlentitydefs module, 582
htmllib module, 580
HTMLParser class (HTMLParser module), 580-585
HTTP protocol, 499, 506
cookies and, 553
httplib module, 506
twisted.protocols package, 540
HTTP servers, 530
HTTPBasicAuthHandler class, 502
HTTPConnection class, 507
HTTPDigestAuthHandler class, 502
httplib module, 493, 506
HTTPPasswordMgrWithDefaultRealm class, 502
HTTPResponse class, 506-507
https protocol, 502, 506
twisted.protocols package, 540
HTTPSConnection class, 507
HTTPServer class, 530-531
HyperText Markup Language (see HTML)
I[ Top ]
IBM DB/2, 299
identifiers, 35
assignment statements, 47
identity (see is)
IDEs (Integrated Development Environments), 22
IDLE (Interactive DeveLopment Environment), 26
debugging in, 470
if statement, 62-63
images, supported by Tkinter module, 414
IMAP4 (Internet Message Access Protocol version 4), 503
immutable objects, 38
implementations of Python, 5
import statement, 140
in (membership test), 50, 54, 58, 60
_ _contains_ _ special method, 111
indentation, 33
blocks and, 34
Indexed-Sequential Access Method (ISAM), 285
indexing
assignment statements, 48
dictionaries, 60
sequences, 54
industry-specific markup languages, 591
inequality (see equality and inequality)
inheritance
classic classes, 82, 94-98
multiple, 133
new-style object model, 97, 104
properties and, 101
input/output (see I/O)
inspect module, 332, 462-465
installing, 14
C-coded Python extensions, 614
IronPython, 21
Jython, 20
Python from binaries, 18
Python from source code, 14-19
resident extension modules, 647, 651, 653
instances, 86-87
getting and setting attributes, 90-91
per-instance methods, 103
pickling, 282-283
int type, 155
integers, 39
bitwise operations, 53
converting numbers to, 155
decimal integer literals, 39
Integrated Development Environments (IDEs), 22
interactive command sessions, 265-269
Interactive DeveLopment Environment (see IDLE)
interactive sessions, 25
Python interpreter, 25
sys.displayhook, 168
internal types, 331
internationalization, 269
codecs module, 199
gettext module, 274-276
locale module, 269-274
resources, 276
Internet Message Access Protocol version 4 (IMAP4), 503
Internet Protocol (IP), 521
Internet servers, 528
interoperability, Python release and debugging builds, 16
inter-process communication (see IPC)
introspection, 329-332, 462-466
dir built-in function, 161
getattr built-in function, 162
I/O (input/output)
console, 260-265
getpass module, 258
operations, optimizing, 488
print statement, 256
readline module, 258-260
stderr, 256
stadin, 257
stdout, 256
IP (Internet Protocol), 521
IPC (inter-process communication), 340
cross-platform mechanism, 360
mmap object, using for, 364
IronPython
installing, 21
interpreter, 30
is (identity test), 50, 162
ISAM (Indexed-Sequential Access Method), 285
ISO 8601 formats, time/date values in, 327
ISO-compliant C compiler, installing Python and, 14
iterables, 40
iteration, file objects, 221
itertools module, 183-185
J[ Top ]
.jar files, 655, 662-664
jarray module, 658
Java
classes, subclassing, 659
compiling Python into, 662-664
embedding Jython, 659-662
Java Development Kit (JDK), 20
Java Native Interface (JNI), 655
Java packages, 656-659
Java Virtual Machines (see JVMs)
JavaBeans, 659
java.util collection classes, 659
JDK (Java Development Kit), 20
JNI (Java Native Interface), 655
.join, 484
joining many strings into one, 484
JVMs (Java Virtual Machines), 6
Jython installation and, 20
Jython, 6, 656
documentation, 10
embedding in Java, 659-662
importing Java packages, 656-659
installing, 20
Jython API, 660--662
jython interpreter, 29
jythonc command, 663
jython.jar file, 656
K[ Top ]
keyboard events (Tkinter), 447
keyboard focus (Tkinter), 411
keyed access, 285
keys (in dictionaries), 44
keywords, 35
Komodo, 27
L[ Top ]
Label class (Tkinter module), 417
lambda expressions, 78
language, lexical structure, 33-38
layout manager, 406
LBYL (look before you leap), 134
Lesser GPL (LGPL), 8
lexical structure of language, 33-38
LGPL (Lesser GPL), 8
LinearAlgebra module, 404
linecache module, 226
lines
blank lines, 34
logical lines, 33
physical lines, 33
Linux
installing Python from binaries, 19
Red Hat Linux releases 6.x/7.x, 9
support for cryptographic-quality pseudorandom numbers, 370
list comprehensions, 67-68
Listbox class (Tkinter module), 417
lists, 43
in-place operations, 56
maintaining order of, 176-179, 183
methods, 56
modifying, 56
optimizing operations on, 478
sequence operators, 55-58
literals, 35, 37
loading modules, 144-147
_ _import_ _ function, 159
local variables of functions, 76
locale module, 269-274
locale sensitivity, string module, 192
locks, 341-342
global interpreter lock (GIL), 341
re-entrant locks (RLock class), 347
logging errors, 136
logging module, 136-138
logical lines, 33
long type, 156
look before you leap (LBYL), 134
loop statements, else clause, 69
loops, optimizing, 486
M[ Top ]
Macintosh
internationalization, 199
Mac OS 9/Mac OS X, 18
making .app files for, 676
Python IDE, 26
Python interpreter on, 23
MacPython, IDE included with, 26
mail protocol, 493
mailing lists, 10
main program, module loading and, 145
make utility, installing Python and, 14
mappings, 44
special methods for, 110
markup, 575
marshal module, 278
marshaling, 278
match object, 210
math module, 365
mbcs codec (Windows), 199
membership testing, sequences, 54
memoization (in deep copies), 172-173
memory
array type and, 375
leaks, exposing, 333
saving, _ _slots_ _ attribute, 102
storing array object, 381
Menu class (Tkinter module), 423-424
Message class (email.Message module), 564-573
Message module, 564
Message class, 564
metaclasses, 116-119
methods, 82, 85
bound and unbound, 91-94
class-level, 99-100
of dictionaries, 60
Java-visible, adding, 663
of lists, 56-57
per-instance, 103
of sets, 58
special, 104-115
of strings, 186-191
superclass, delegating to, 96-97
Microsoft Installer (MSI), 18
Microsoft .NET (see IronPython)
Microsoft SQL Server, 299
Microsoft web servers, installing Python CGI scripts on, 552
MIME (Multipurpose Internet Mail Extensions), 561, 564
mimetools module, 573
minidom module, 599-609
MLab module, 403
mmap module, 360
mmap object, 360-364
mode attribute, 219
mode string, file objects, 217
mod_python, 558
Modules, 280
modules, 139-152
DBAPI-compliant, 298
installing, 647, 651, 653
loading, 144-147, 159, 617
module object, 139-142
attributes, 141-143
packages and, 149
modulo, ternary exponentiation-and-modulo, 165, 115
money-related computations, 372
Morsel class (Cookie module), 555
MSI (Microsoft Installer), 18
mssqldb module, 299
msvcrt module, 264
multiple inheritance, 133
multiple precision arithmetic (see gmpy module)
Multipurpose Internet Mail Extensions (MIME)
multiset (see defaultdict type)
multithreading (see threads)
mutable objects, 38
shelve module and, 284
mx package, 306, 319
mx.DateTime module, 319-327
mxODBC module, 298
MySQLdb module, 299
N[ Top ]
name attribute, 219
named arguments in function calls, 74-75
names (see variables)
namespaces, functions, 76
nested functions, 77
network encodings, 561
Network News Transport Protocol (see NNTP)
network protocol modules
client-side, 493, 503, 506, 511, 515, 516, 519
server-side, 520, 528
newsgroups, 10
new-style classes, 104
NIST module, 327
NNTP class, 512-514
NNTP (Network News Transport Protocol), 493, 511
nntplib module, 493, 511-512
Node class (minidom module), 600-602, 608
None, 45
returned by functions reaching end of body, 73
nonpure distributions, 667
nonsequential access, file objects, 218
numarray module, 378
numbers, 38
complex, 40
decimal, 372-373
floating-point, 39, 365, 372
integers, 39
pseudorandom, 370
returning absolute value of, 159
Numeric module, 378-402
array object, 378-380
blitz function, 646
optional modules supplied by, 403
ufuncs, 399
numeric operations, 52-53
operator module, 368-369
special methods for, 113-115
O[ Top ]
object models, 81
classic, 82, 94
new-style, 104
object type, 98, 156
object-oriented Python, 81
objects
assigning, 172
first-class, classes as, 82
immutable, 38
mutable, 38
mutable/immutable, 284
polymorphism, 222
serializing/deserializing, 278
odbc module, 298
ODBC (Open DataBase Connectivity), 298
Open DataBase Connectivity (ODBC), 298
OpenDirector class, 502
operations, in-place, with Numeric ufuncs, 391
operators, 35, 50-58
chaining of comparisons, 51
numeric, 52-53
operator module, 368-369
precedence, 51
on sequences, 54-58
short-circuiting, 51
optimization, 451, 474
benchmarking, 475
developing Python applications, 474
large-scale, 476, 478
profiling, 480
small-scale, 483-488
optional parameters of functions, 71
options, command-line, 23-24, 179
optparse module, 179-182
Oracle RDBMS, 299
org.python.core package, 661
os module, 240
environ attribute, 354
functions, 242-246
path-string attributes, 241
P_WAIT attribute, 357
system function, 354
OSError, 240
os.path module, 246-249
P[ Top ]
packages, 149
parameters of functions, 71
parent widgets, 406, 420
parentheses (see ())
Parser module, 564
partial application, 175
pass statement, 69
passing arguments to functions, 74
PATH variable, python interpreter and, 22
path-string attributes, os module, 241
pdb module, 466
PEPs (Python Enhancement Proposals), 8
performance, 476
arrays and, 375
asyncore/asynchat modules, 558
big-O notation and concepts, 476-479
CGI scripts, 557
DBM modules, 287
extension modules, special-purpose, 5
generator expressions, 78-79
pickle/cPickle modules, 279
slicing array object, 382
threads, 340, 347
Twisted package, 558
per-instance methods, 103
permissions of files, 242
persistence, 277
Personal Web Server (PWS), 552
PhotoImage class, 414
physical lines, 33
pickle module, 279-283
PIL (Python Imaging Library), 414
pipes, 340, 355-360
plain assignment statements, 47
polymorphism, 94, 98, 101
to file objects, 222
type checking and, 157
POP mailboxes, accessing, 503
POP3 class (poplib module), 504
POP3 (Post Office Protocol version 3), 503
twisted.protocols package, 540
poplib module, 493, 503
portability
distributing Python modules, 672
extension modules and, 5
positional arguments to functions, 74-75
when building dictionaries, 44
Post Office Protocol version 3 (see POP3)
PostgreSQL, 299
PowerArchiver, uncompressing/unpacking, 15
pprint module, 197
PrettyPrinter class, 197
print statement, 61, 256
printing, complicated data in readable format, 197
priority queue, 177
process environment, 353
processes, 340
Profile class, 480
profiling, 451
program termination, 169, 337-338
programming paradigms, ability to mix and match in Python, 81
prompt string, Python interactive sessions, 25
properties, 100-101, 156
importance of, 101
and inheritance, 101
protocol module (Twisted package), 540-543
pseudorandom numbers, 370
PSF (Python Software Foundation), 8
PSP (Python Server Pages), 559
embedding Python code in HTML, 586
pstats module, 481
psycopg module, 299
PTL (Python Template Language), 560
pulldom module, 605-606
punctuation
in regular expressions, 201
in string formatting, 193-196
in URLs, 494
(see also Symbols)
pure distributions, 667
PWS (Personal Web Server), 552
.py. .pyc, and .pyo files, 28-29, 145
_ _init_ _.py in packages, 149-150
.pythonrc.py, 339
setup.py file, 151, 614, 667, 673-675
py2exe tool, 675
PyApache, 558
Py_CompileString function (Python C API), 649
PyException Java exception, 661
PyObject Java object, 662
PyPy, 7
pyrex, 646, 650-654
pysqlite, 300-301
Python, 3, 141, 146, 616, 620
compiling into Java, 662-664
development, 8
development environments, 26
documentation, 10
embedding/extending, 613
extension modules, 5
extensions, 614
implementations, 5
installing, 14
interpreter, 22-25
language, 3
library, 5
modules, 5
newsgroups/mailing lists, 10
object models, 81
object-orientation, 81
programming paradigms, 81
programs, 28, 138
resources, 9, 11
SIGs, 11
upgrades, overwriting customizations, 338
versions, 8, 303, 462
Python 2.5, exception handling, 124
Python C API, extending CPython with, 614
building/installing C-coded Python extensions, 614
Python Database API 2.0 standard (see DBAPI)
Python Enhancement Proposals (PEPs), 8
Python Imaging Library (PIL), 414
Python Server Pages (see PSP)
Python Template Language (PTL), 560
PYTHONHOME environment variable, 22
PythonInterpreter class (Jython API), 660
python.path option, 657
PYTHONPATH environment variable, 23, 144
PYTHONSTARTUP environment variable, 23, 339
pythonw interpreter, 29
PythonWin, 26
pytz module, 313
PyXML, 591
Q[ Top ]
QP encoding (Quoted Printable encoding), 562
Queue module, 342-343
ideal threaded-program architecture, 350
Quixote, 560
quopri module, 562
Quoted Printable encoding (QP encoding), 562
quoted strings, 40
R[ Top ]
Radiobutton class (Tkinter module), 418
raise statement, 69, 128
raising to power (see exponentiation operators)
Random class, 370
random module, 370
raw strings, 42
RDBMS (relational database management system), 277
RDF (Resource Description Framework), 591
re module, 201-212
reactor object (Twisted package), 540-541
readline module, 258-260
ReadLine package for Windows, 25
rebinding, 46, 74
recursion, 80
RedHat Package Manager (RPM), installing Python from binaries, 19
references
reference counting, C-coded extension modules, 620
reference loops, 336
weak, 336
reflection (see introspection)
regular expression object, 207-210
regular expressions, 201-212
common idioms, 202
groups, 204
match object, 210
matching versus searching, 206
pattern-string syntax, 201
relational database management system (RDBMS), 277
Remote Procedure Calls (RPCs), 516
repetition, sequences, 54
repr module, 198
Resource Description Framework (RDF), 591
resources, 9
PBF, 11
print, 12
Python Cookbook, 11
Python Journal, 11
Python on Windows, 292
Python source code, 11
return statement, 73
reversing a sequence, 57-58, 156
rfc822 module, 573
RLock class (threading module), 344
RPCs (Remote Procedure Calls), 516
RPM (RedHat Package Manager), installing Python from binaries, 19
S[ Top ]
SAP DB, 299
SAX (Simple API for XML), 593
parsing XHTML, 598
parsing XML, 593
SAXException class (xml.sax package), 593
saxutils module, 597
Scale class (Tkinter module), 419
sched module, 316
SciTE, 27
scopes (see namespaces)
scripts, 28, 557
CGI, 550, 557
GUI, running standalone, 405
setup.py, 667
Scrollbar class (Tkinter module), 419
SCXX library, 645
search path for modules, 144
searching for a regular expression, 210
security
cookies and, 553
cryptographic-quality pseudorandom numbers, 370
select module, 533
self parameter, 85, 91
Semaphore class (threading module), 344, 349, 358
sentinel, 98
sequences, 40-43, 53-58
arrays, 375-378
generators, 78-79
indexing, 48, 50, 54-56, 380-381
inserting into, 56-57
iterables, 40
iterators, 65-66, 183-185
list comprehensions, 67
list methods, 56-58
slicing, 48, 50, 55-56, 381-383
sorting, 57
special methods for, 109
string methods, 186-191
sequential access, file objects, 218
serialization, 277
marshal module, 278
pickle/cPickle modules, 279, 283
shelve module, 284
ServerProxy class, xmlrpclib module, 518-519
servers, 493
Apache, 552, 557
custom Python, 558
HTTP, 506, 530
Internet, 528
Microsoft web, installing Python CGI scripts on, 552
SMTP, 505
Telnet, 515
web, subclassing BaseHTTPServer, 558
Xitami, 553
XML-RPC, 517
server-side web scripting, 545-560
CGI, 545-553
CherryPy, Django, Pylon, Turbogears, 559
cookies, 553-557
FastCGI, 557
Quixote, 560
web.py, 560
Webware, 559
WSGI, 558
servlets, Jython, 664
sets, 43, 58, 156
special methods for, 110
setup.cfg file, 673
setup.py script, 151, 667
SGML (Standard General Markup Language), 575
sgmllib module, 576
SGMLParser class
HTMLParser class, compared to, 583
sgmllib module, 576
shallow copies, 55, 58, 60, 172
shelve module, 284
short-circuiting operators, 51
shutil module, 252
SIGs (Special Interest Groups), 11
Simple API for XML (see SAX)
Simple Mail Transport Protocol (see SMTP)
simple statements, 37-38
SimpleHTTPServer module, 530
SimpleXMLRPCServer module, 530
Simplified Wrapper and Interface Generator (SWIG), 646
site customization, 338
site module, 338
sitecustomize module, 199, 338
site.py file, 338
slicing, 48, 50, 55-56
Numeric arrays, 380-381
slice object, 110, 156
SMTP (Simple Mail Transport Protocol), 503-505
smtplib module, 493, 505
socket module, 521
functions, 521
socket class, 523
sockets, 520-528
event-driven programming, 533-544
methods, 523-525
TCP and UDP, 525-527
timeout behavior, 528
SocketServer module, 528
source code, installing Python from, 14-19
source files, 139
as modules, 140
Python modules in distribution utilities, 669
Source Navigator (Red Hat), 26
Special Interest Groups (SIGs), 11
special methods, 104-115
for containers, 109
general-purpose, 104
for number objects, 113
Spyce, Cheetah and, 587
SQL (Structured Query Language), 277
SQLite (see pysqlite)
stack (in debugging), 462-470
propagation of exceptions, 127-129
stack level in warnings, 473-474
stack traces (tracebacks), 125-127, 135-136, 455-456, 466
Standard General Markup Language (SGML), 575
standard input, error, output 171
(see also stderr; stdin; stdout)
stat module, 249
statements
assignment statements, 47-49
break, 68
compound statements, 38
continue, 68
control flow
break, 68
continue, 68
for, 64-68
if, 62
pass, 69
raise, 69
try, 69
while, 63
with, 69
def, 70
del, 49
expressions, 37
for, 64-68
if, 62
pass, 69
print, 61, 256
raise, 69
return, 73
simple statements, 37
terminating, 34
try, 69
while, 63
with, 69
static methods, 99, 157
stderr, 136, 171, 256
stdin, 171
stdout, 171, 256
str, 157, 186, 273
(see also strings)
string module, 191-193
locale sensitivity, 192
StringIO module, 229
strings, 40-42, 186-191
escape sequences, 41
formatting, 193-197
methods, 186-191
mutable, 178
optimizing operations on, 478
raw-string syntax, 42
regular expressions, 201-212
as sequences, 53-55
struct formats, 227
template strings, 196
triple-quoted syntax, 41
Unicode, 198-200
struct module, 227-229
Structured Query Language (SQL), 277
subprocess module, 358-360
summing sequences of numbers, 167
subclass relationships, 83
superclass methods, delegating to, 96
super type, 97, 157
SWIG (Simplified Wrapper and Interface Generator), 646
sys module
and error handling, 127, 133, 136
and module loading, 144, 147
stderr, stdin, stdout, 127, 136, 171
system testing, 452
SystemExit exception, 129
T[ Top ]
tags, HTML, 575-584
tar program, 15
tarfile module, 233-235
TCP echo servers, 525
TCPServer class, 528
Telnet class, 515-516
telnet protocol, 493, 515
telnetlib module, 357, 493, 515
tempfile module, 223
template strings, 196
terminating statements, 34
termination functions, 337
ternary operator, 51
TestCase class (unittest module), 459-460
test-first development, 452
testing, 451-461
text, filling, 197
Text class (Tkinter module), 426
text editors with Python support, 27
text input/output, 256
text wrapping, 197
Textpad class (curses module), 263
Thread class (threading module), 346
thread module, 341
threaded program architecture, 350-353
threading module, 344-349
ThreadingTCPServer class, 528
ThreadingUDPServer class, 528
threads, 341-353
program architecture, 350-353
synchronizing, 346-349
thread safety, DBAPI, 293
timedelta class, datetime module, 312
timeit module, 484
timestamps, 307
in databases, 295
in logging, 138
time class, datetime module, 308
time module, 302-306
time-tuple, 302
time zones, 313
tkFont module, 433
Tkinter events, 446-448
Tkinter module, 406
attributes, 406
Button class, 415
Canvas class, 436
Checkbutton class, 415
Entry class, 416
Event class, 446
events, 446
Frame class, 420
geometry management, 442, 445
Label class, 417
Listbox class, 417
Menu class, 423
Radiobutton class, 418
Scale class, 419
Scrollbar class, 419
Text class, 426
Toplevel class, 420
variable object, 413
widgets supplied by, 409, 415
tokens, 35-37
toolkits, 405
Toplevel class (Tkinter module), 420
traceback messages, 121
traceback module, 466
tracebacklimit attribute, 171
transport object (Twisted package), 542
troubleshooting
error-specific information, 129
memory leaks, 333
(see also debugging)
True, 45
truncating division, 52
truth values (evaluation), 45
try statement, 69
exception handling, 121-123, 135
tuples, 42, 157
in string formatting, 195
sequence operations, 55
TurboGears, 559
Twisted package, 533-541
performance characteristics, 558
two's complement, 53
type checking, 157
type codes in arrays, 375
type type, 117, 157, 332
types
built-in, 154-158
defining new with C-coded Python extensions, 638
internal, 331
types module, 332
U[ Top ]
UDP echo servers, 527
UDPServer class, 528
ufuncs (universal functions), Numeric module, 399-400
unbound methods, 91
Unicode strings, 198-201
character database, 200
codecs module, 199
converting strings to, 198
literals, 42
Tkinter and, 406
unicodedata module, 200
Uniform Resource Locators (see URLs)
unittest module, 457-461
using large amounts of data, 461
universal functions (ufuncs), Numeroc module, 399
universal newlines (reading textfiles), 218
Unix
dbm module, 287
installing Python from source, 17
mmap function, 361
Python IDEs, 26
running Python scripts, 29
Unix-to-Unix (UU) encoding, 563
URL-based file-like objects, 497
urllib module, 493-498
urllib2 module, 493, 498-502
urlparse module, 493
URLs (Uniform Resource Locators), 493
access to network protocols, 493
authentication, 502
reading data from, 495
Usenet News, 511
user customization, 339
user input, errors depending on, 136
user module, 339
UserDict module, 178
UserList module, 178
UTC (Coordinated Universal Time), 302
Utils module (email package), 570
uu module, 563
UU (Unix-to-Unix) encoding, 563
V[ Top ]
variables, 46
binding, 46
built-in, 138
class-private, 85
global, thread synchronization and, 346
identifiers, 35
module-private, 142
vim program, 27
Visual C++ (Visual Studio), 15-16, 27
Visual Studio .NET IDE, 27
W[ Top ]
W3C (World Wide Web Consortium), 591
warnings module, 471-473
WConio module, 265
weakref module, 333-336
web servers, subclassing BaseHTTPServer, 558
web.py, 560
Webware, 559, 586
whichdb module, 287
while statement, 63
else clause, 69
whitespace
check is string is all whitespace, 192
indentation, 34
separates tokens, 35
splitting strings, 189
Widget class (Tkinter module), 408, 411-412, 443-445
widgets, 405, 408
canvas, 436, 438, 440
checkboxes, 415
child/parent, 420
color options, 409
container, 420
length options, 410
listboxes, 417
menus, 423, 425
pushbuttons, 415
radiobuttons, 418
scrollbars, 419
text, 426, 428, 432
text entry fields, 416
Tkinter module, 415
win32all package, 646
Windows
applications, embedding/extending Python with COM, 646
CGI scripting on, 549
installing Python from binaries, 19
installing Python from source, 15
IronPython, 6
keys into os.environ, 354
mbcs codec, 199
mmap function, 361
py2exe tool, 675
Python scripts, 29
resource for further information, 292
Wing IDE, 27
WinZip program, 15
with statement (Python 2.5), 69, 125
World Wide Web Consortium (W3C), 591
wrapping text, 197
WSGI, 558
wxWindows toolkit, 26
X[ Top ]
XHTML, 575
changing/outputting with minidom, 609
parsing, 583, 598, 605
Xitami servers, installing Python CGI scripts on, 553
XML (eXtensible Markup Language), 591
generating, 606
parsing, 592, 599
xml package, 591
xml.dom package, 599
XMLGenerator class (saxutils module), 597
XML-RPC, 493, 516, 519
xmlrpclib module, 517
XML-RPC servers, 517, 531
xmlrpclib module, 517
xml.sax package, 593-597
XPath, 591
xrange type, 158
XSLT, 591
Y[ Top ]
yield statement (generators), 76
Z[ Top ]
ZIP files, importing from, 144, 148
zipfile module, 235-239
zlib module, 239
Zope, 557
Zurück zu Python in a Nutshell