Index

Symbols

!r formatting code, Solution
% (percent) operator, Discussion, Solution
format() function vs., Discussion
* (star) operator
EBNFs and, Solution
**kwargs, Solution
decorators and, Discussion
enforcing signature on, Problem, Discussion
help function and, Discussion
wrapped functions and, Discussion
*args, Solution
decorators and, Discussion
enforcing signature on, Problem, Discussion
wrapped functions and, Discussion
+ (plus) operator, Discussion, Solution
-O option (interpreter), Discussion
-OO option (interpreter), Discussion
-W (warnings), Discussion
all option, Solution
error option, Solution
ignore option, Discussion
. (dot) operator, Solution, Selectively eliminate attribute access
< (less than) operator, date comparisons with, Discussion
== operator, Solution
? (question mark) modifier in regular expressions, Solution
\$ (end-marker) in regular expressions, Discussion
_ (single underscore)
avoiding clashes with reserved words, Discussion
naming convention and, Solution
__ (double underscore), naming conventions and, Solution

A

abc module, Problem
abspath() (os.path module), Discussion
abstract base classes, Problem, Discussion
collections module and, Problem, Discussion
predefined, Discussion
abstract syntax tree, Problem, Discussion
abstraction, gratuitous, Avoid gratuitous abstraction
@abstractmethod decorator (abc module), Solution
accepting script via input files, Problem
accessor functions, Problem, Discussion
adjusting decorators with, Problem, Discussion
ACCESS_COPY (mmap module), Solution
ACLs, Discussion
actor model, Problem, Discussion
addHandler() operation (logging module), Discussion
add_argument() method (ArgumentParser module), Discussion, Discussion
Advanced Programming in the Unix Environment, 2e (Stevens, Rago), Discussion
algorithms, Data Structures and Algorithms, Discussion
filtering sequence elements, Problem, Discussion
finding most frequent item (sequences), Problem, Discussion
limited history, keeping, Problem, Discussion
sorting for largest/smallest N items, Problem, Discussion
unpacking, Data Structures and Algorithms, Discussion
anonymous functions
defining, Problem, Discussion
variables, capturing, Problem, Discussion
Apache web server, Discussion
append() method (ElementTree module), Discussion
%apply directive (Swig), Discussion
archives
creating, Problem
formats of, Discussion
unpacking, Problem
argparse module, Solution, Discussion, Discussion
.args attribute (Exceptions), Discussion
ArgumentParser instance, Discussion
arguments
annotations, Problem
cleaning up in C extensions, Discussion
multiple-dispatch, implementing with, Problem, Discussion
arrays
calculating with large numerical, Problem, Discussion
high-performance with Cython, Problem, Discussion
in C extensions, Discussion
large, sending/receiving, Problem, Discussion
NumPy and, Problem, Discussion
operating on, with extension functions, Problem, Discussion
readinto() method and, Discussion
writing to files from, Discussion
assertRaises() method (unittest module), Solution, Discussion
assertRaisesRegex() method (unittest module), Discussion
ast module, Discussion, Discussion, Problem, Discussion
asynchronous processing, Problem, Discussion
attrgetter() function (operator module), Discussion
authentication
encryption vs., Discussion
hmac module, Problem, Discussion
passwords, prompting at runtime, Problem
requests package and, Solution
simple, Problem, Discussion
testing with httpbin.org, Discussion

B

b16decode() function (base64 module), Problem
binascii functions vs., Discussion
b16encode() function (base64 module), Problem
binascii functions vs., Discussion
base64 module, Problem
binascii module vs., Solution
BaseException class, Solution, Discussion
except statements and, Discussion
BaseRequestHandler (socketserver module), Discussion
basicConfig() function (logging module), Solution, Discussion
bin() function, Problem, Discussion
binary data
arrays of structures, reading/writing, Problem, Discussion
encoding with base64 module, Problem
memory mapping, Problem, Discussion
nested records, reading, Problem, Discussion
reading into mutable buffers, Problem, Discussion
reading/writing, Problem, Discussion
unpack_from() method and, Discussion
variable-sized records, reading, Problem, Discussion
binary integers, Problem, Discussion
binascii module, Problem, Discussion
bind() method (Signature objects), Discussion, Solution
bind_partial() method (Signature objects), Discussion
bit_length() method (int type), Discussion
BNF, Solution
boundscheck() decorator (Cython), Discussion
buffer attribute (files), Solution
Buffer Protocol, Discussion, Solution
BufferedWriter object (io module), Discussion
built-ins
containers, Avoid gratuitous abstraction
exception class, Discussion
methods, overriding, Solution
byte strings
as return value of read(), Solution
encoding with base64, Discussion
indexing of, Discussion
performing text operations on, Problem, Discussion
printing, Discussion
writing to text files, Problem
bytes, interpreting as text, Solution
BytesIO() class (io module), Problem, Discussion, Discussion
bz2 compression format, Discussion
bz2 module, Problem, Discussion
compresslevel keyword, Discussion

C

C APIs, Problem, Discussion
C extension programming, Discussion, C Extensions
APIs, defining/exporting, Problem, Discussion
aquiring GIL in, Discussion
capsule objects in, Problem, Discussion
ctypes module and, Problem, Discussion
Cython, wrapping code in, Problem, Discussion
file-like objects, reading, Problem, Discussion
filenames, passing to, Problem, Discussion
function pointers, converting to callables, Problem, Discussion
GIL and, Solution, Discussion
GIL, releasing in, Problem
iterables from C, consuming, Problem, Discussion
loading modules, Discussion
modules, building, Solution
null-terminated strings, passing, Problem, Discussion
opaque pointers in, Problem, Discussion
open files, passing to, Problem, Discussion
operating on arrays with, Problem, Discussion
Python callables in, Problem, Discussion
Python/C threads, mixing, Problem, Discussion
segmentation faults and, Problem, Discussion
strings, converting to Python objects, Problem, Discussion
Swig, wrapping with, Problem, Discussion
Unicode strings, passing, Problem, Discussion
unknown string type and, Problem, Discussion
writing, modules, Problem, Discussion
C structures, Discussion
calendar module, Discussion
__call__() method (metaclasses), Problem, Discussion, Solution
callback functions
carrying extra state with, Problem, Discussion
inlining, Problem, Discussion
capsule objects, Problem, Discussion
C APIs, defining/exporting with, Problem, Discussion
Celery, Discussion
center() method (str type), Solution
certificate authorities, Discussion
CFFI, Discussion
CFUNCTYPE instances (ctypes module), Discussion
chain() method (itertools module), Problem, Discussion
chained exceptions, Solution, Discussion
ChainMap class (collections module), Problem, Discussion
update() method vs., Discussion
chdir() function (os module), Discussion
check_output() function (subprocess class), Solution
Chicago, Illinois, Solution, Solution
choice() function (random module), Solution
__class__ attribute, Discussion, Discussion
class decorators, Solution, Problem, Discussion
data models and, Discussion
mixin classes vs., Discussion
mixins and, Discussion
classes, Classes and Objects, Discussion
abstract base classes, Problem, Discussion
attribute definition order, Problem, Discussion
caching instances of, Problem
closures vs., Problem, Discussion
coding conventions in, Problem, Discussion
constructors, multiple, Problem, Discussion
containers, custom, Problem, Discussion
data models, implementing, Problem, Discussion
decorators, Solution
decorators, defining in, Problem, Discussion
defining decorators as, Problem, Discussion
delegating attributes, Problem, Discussion
descriptors and, Problem, Discussion
extending properties in subclasses, Problem, Discussion
extending with mixins, Problem, Discussion
implementing state for objects/machines, Problem, Discussion
inheritance, implementation of, Discussion
initializing members at definition time, Problem, Discussion
initializing of data structures in, Problem, Discussion
lazy attributes and, Problem
mixins, Discussion, Problem, Discussion
private data in, Problem, Discussion
replacing with functions, Problem, Discussion
statements, metaclass keyword in, Problem, Discussion
super() function and, Problem, Discussion
supporting comparison operations, Problem, Discussion
type system, implementing, Problem, Discussion
__init__() method, bypassing, Problem, Discussion
@classmethod decorator, Discussion
decorating class methods with, Problem, Discussion
__func__ attribute and, Discussion
client module (http package), Discussion
clock() function (time class), Discussion
close() method (generators), Discussion
closefd argument (open() function), Solution
closures
accessing variables inside, Problem, Discussion
capturing state with, Solution, Discussion
classes vs., Problem, Discussion
converting classes to functions with, Solution
nonlocal declarations and, Discussion
cmath module, Solution
code readability and string templates, Discussion
coding conventions, Problem, Discussion
collections module
ChainMap class, Problem, Discussion
Counter class, Problem, Discussion
defaultdict class, Solution
deque class, Problem, Discussion
implementing custom containers with, Problem, Discussion
namedtuple() function, Solution
OrderedDict class, Problem, Discussion
combinations() function (itertools module), Solution
combinations_with_replacement() function (itertools module), Solution
combining() function (unicodedata module), Discussion
command-line options, parsing, Utility Scripting and System Administration, Problem, Solution
compare_digest() function (hmac module), Solution
comparison operations, Problem, Discussion
compile() function (ast module), Solution
compile() function (re module), Discussion
complex() function, Solution
complex-valued math, Problem, Discussion
compress() function (itertools module), Discussion
compressed files, reading/writing, Problem, Discussion
specifying level of, Discussion
concurrency, Concurrency, Discussion
actor model and, Problem, Discussion
coroutines, Problem, Discussion
event-driven I/O and, Discussion
GIL, Problem, Discussion
parallel programming, Problem, Discussion
polling thread queues, Problem, Discussion
threads, Problem, Discussion
with generators, Problem, Discussion
Condition object (threading module), Discussion
conditionals and NaN values, Discussion
config file
Python code vs., Discussion
Python source file vs., Discussion
ConfigParser module, Solution, Discussion
configuration files, Problem
connect() function (sqlite3 module), Solution
connection (multiprocessing module), Problem, Discussion
constructors, defining multiple, Problem, Discussion
containers, custom, Problem, Discussion
iterating over items in separate, Problem, Discussion
__iter__() method and, Problem, Discussion
context managers
defining, Problem, Discussion
use instance as, Discussion
context-management protocols, Problem, Discussion
contextlib module, Discussion
@contextmanager decorator (contextlib module), Discussion, Discussion
contextmanager module, Discussion
cookies, Solution
copy2() function (shutil module), Discussion
copying directories/files, Problem
copytree() function (shutil class), Solution, Discussion
coroutines, Problem, Discussion
capturing state with, Solution
inlining callback functions with, Solution
Counter objects (collections module), Problem, Discussion
country_timezones dictionary (pytz module), Discussion
cProfile module, Solution
CPU-bound programs, Solution
CPUs, restricting use of, Problem
critical() function (logging module), Solution
cryptography, Discussion
CSV files, reading/writing, Problem, Discussion
csv module, Problem, Discussion
ctypes module, Problem, Discussion
alternatives to, Discussion
memory addresses, wrapping, Problem, Discussion
custom exceptions, Discussion
Cython, Discussion
array handling with, Discussion
high-performance arrays with, Problem, Discussion
memoryviews in, Discussion
releasing the GIL, Discussion
setup.py file, Solution, Solution
wrapping existing code in, Problem, Discussion

D

daemon processes (Unix), Problem, Discussion
daemonic threads, Solution
data
pickle module and, Problem, Discussion
serializing, Problem, Discussion
transforming/reducing simultaneously, Problem, Discussion
data analysis, Discussion
data encapsulation, Problem, Discussion
data encoding
CSV files, reading/writing, Problem, Discussion
for RPCs, Discussion
hexadecimal digits, Problem, Discussion
JSON, reading/writing, Problem, Discussion
with base64 module, Problem
XML, extracting data from, Problem, Discussion
data models, Problem, Discussion
data processing
dictionaries, converting to XML, Problem, Discussion
nested binary records, reading, Problem, Discussion
parsing large XML files, Problem, Discussion
relational databases and, Problem, Discussion
statistics, Problem, Discussion
summarizing, Problem, Discussion
variable-sized binary records, reading, Problem, Discussion
XML namespaces, Problem, Discussion
XML, parsing/modifying/rewriting, Problem, Discussion
data structures, Data Structures and Algorithms, Discussion, Use the built-in containers
cyclic, managing memory in, Problem, Discussion
dictionaries
grouping records by field, Problem, Discussion
sorting by common keys, Problem, Discussion
heaps, Problem, Discussion
initializations of, simplifying, Problem, Discussion
multidicts, Problem, Discussion
database API (Python), Problem, Discussion
strings and, Discussion
datagrams, Discussion
date calculations, Problem, Discussion
datetime module, Problem, Discussion
databases and, Discussion
date calculations with, Problem, Discussion
replace() method, Discussion
strptime() method, Discussion
time conversions, Problem, Discussion
time zones and, Solution
timedelta object, Solution
dateutil module, Discussion
deadlock avoidance, Discussion
deadlocks, Problem, Discussion
dining philosophers problem, Discussion
watchdog timers and, Discussion
__debug__ variable, Discussion
debug() function (logging module), Solution
debugger, launching, Solution
debugging, Discussion
decimal module, Problem, Discussion
databases and, Discussion
formatting output of, Discussion
decode() method (str type), Solution
decorators, Problem, Discussion
adding function arguments with, Problem, Discussion
adjustable attributes for, Problem, Discussion
class methods, applying to, Problem, Discussion
defining as class, Problem, Discussion
defining in classes, Problem, Discussion
forcing type checking with, Problem, Discussion
multiple-dispatch, implementing with, Discussion
optional arguments for, Problem, Discussion
patching classes with, Problem, Discussion
preserving function metadata in, Problem, Discussion
static methods, applying to, Problem, Discussion
unwrapping, Problem, Discussion
with arguments, Problem, Discussion
wrappers as, Problem, Discussion
__wrapped__ attribute, Discussion
deepcopy() function (copy module), Avoid making unnecessary data structures or copies
defaultdict object (collections module), Solution
groupby() function vs., Discussion
ordinary dictionary vs., Solution
__delattr__() method (delegation), Discussion
delegation
inheritance vs., Discussion
of attributes, Problem, Discussion
__delete__() method (descriptors), Solution
DeprecationWarning argument (warn() function), Solution
deque class (collections module), Problem, Discussion
appending, Discussion
popping, Discussion
descriptors
creating, Problem, Discussion
data models, implementing, Problem, Discussion
extending, Discussion
lazy attributes and, Problem, Discussion
type system, implementing, Problem, Discussion
deserializing data, Problem, Discussion
Design Patterns: Elements of Reusable Object-Oriented Software (Gamma, Helm, Johnson, and Vlissides), Discussion
dest argument (add_argument() method), Discussion
detach() method, Discussion
dict() function, Discussion, Discussion
dictionaries
comparing, Problem, Discussion
converting to XML, Problem, Discussion
Counter objects and, Discussion
defaultdict vs., Solution
grouping records based on field, Problem, Discussion
JSON support for, Discussion
keeping in order, Problem, Discussion
multiple values for a single key in, Problem, Discussion
removing duplicates from, Solution
sorting, Problem, Discussion
sorting list of, by common key, Problem, Discussion
subsets, extracting, Problem, Discussion
dictionary comprehension, Solution
dining philosophers problem (deadlocks), Discussion
directories
as runnable scripts, Problem, Discussion
copying, Problem
moving, Problem
temporary, Problem, Discussion
directory listings, Problem, Discussion
dis module, Problem, Discussion
discarding vs. filtering iterables, Discussion
distributed systems and property calls, Discussion
domain sockets (Unix), Discussion, Solution
connecting interpreters with, Discussion
DOTALL flag (re module), Discussion
dropwhile() function (itertools module), Solution
dump() function (pickle module), Solution
dumps() function (json module), Solution
indent argument, Discussion
sort_keys argument, Discussion
dumps() function (pickle module), Solution
dup2() function (os module), Discussion

E

EBNF, Solution
ElementTree module (xml.etree), Discussion, Problem, Discussion
creating XML documents with, Problem, Discussion
iterparse() function, Discussion
parse() function, Discussion
parse_and_remove() function, Discussion
parsing namespaces and, Discussion
parsing/modifying/rewriting files with, Problem, Discussion
empty() method (queue module), Discussion
encode() method (str type), Solution
encoding text data, Problem, Discussion
changing in open files, Problem, Discussion
passing to C libraries, Problem, Discussion
pickling and, Discussion
encryption vs. authentication, Discussion
end argument (print() function), Solution
endswith() method (str type), Solution
pattern matching with, Solution
__enter__() method (with statements), Problem, Discussion
enumerate() function, Problem, Discussion
environ argument (WSGI), Discussion
error messages, terminating program with, Problem
error() function (logging module), Solution
escape() function (html module), Solution
escape() function (xml.sax.saxutils module), Discussion
Event object (threading module), Problem, Discussion
event-driven I/O, Problem, Discussion
except statement, Discussion, Solution
chained exceptions and, Solution
reraising exceptions caught by, Problem
Exception class, Discussion
handler for, Solution
exceptions
catching all, Problem
creating custom, Discussion
handling multiple, Problem
raising in response to another exception, Problem
reraising, Problem
SystemExit, Solution
testing for, Problem
with statements and, Discussion
exec() function, Problem, Discussion
execve() function (os module), Solution
__exit__() method (with statements), Problem, Discussion
@expectedFailure decorator, Discussion
exponential notation, Solution
%extend directive (Swig), Discussion
external command
executing, Problem
getting output, Problem

F

factory functions, Solution
faulthandler module, Problem, Discussion
fdel attribute (properties), Discussion
fget attribute (properties), Discussion
FieldStorage() class (cgi module), Discussion
file descriptor
passing between processes, Problem, Discussion
wrapping in object, Problem
file-like objects, reading from C, Problem, Discussion
FileInput class, Discussion
helper methods, Discussion
fileinput module (built-in), Solution
FileIO class (io module), Discussion
FileNotFoundError exception, Solution
files, Files and I/O, Discussion
accepting scripts via, Problem
binary data, reading/writing, Problem, Discussion
bypassing name encoding, Problem, Discussion
bytes, writing to text, Problem
changing encoding in open, Problem, Discussion
compressed, reading/writing, Problem, Discussion
copying, Problem
creating new, Problem, Discussion
defining modules in multiple, Problem, Discussion
detach() method, Discussion
directory listings, getting, Problem, Discussion
finding by name, Problem
getfilesystemencoding() function (sys module), Problem, Discussion
headers, unpacking, Solution
iterating over fixed-sized records in, Problem
line ending, changing, Problem, Discussion
manipulating pathnames of, Problem, Discussion
memory mapping, Problem, Discussion
moving, Problem
mutable buffers, reading into, Problem, Discussion
names, passing to C extensions, Problem, Discussion
newlines, Discussion
open() function, Problem, Discussion
open, passing to C extensions, Problem, Discussion
path module (os), Problem, Discussion
printing bad filenames for, Problem, Discussion
printing to, Problem
reading, Problem, Discussion
readinto() method of, Discussion
saving objects to, Problem, Discussion
separator character, changing, Problem, Discussion
temporary, Problem, Discussion
testing for existence of, Problem, Discussion
text data from, Problem, Discussion
unpacking, Discussion
wrapping descriptors in objects, Problem
x mode of open() function, Problem, Discussion
files list, Discussion
filesystem, byte strings and, Discussion
fill() function (textwrap module), Discussion
filter() function, Solution
filtering
discarding iterables vs., Discussion
normalization of Unicode text and, Discussion
sequence elements, Problem, Discussion
token streams, Solution
find Unix utility, Discussion
find() method (str type)
pattern matching with, Solution
search/replace text and, Solution
findall() method (re module), Solution
finditer() method (re module), Discussion
find_library() function (ctypes.util module), Discussion
float()
decimal arithmetic and, Problem, Discussion
format() function (built-in), Problem, Discussion
j suffix for, Solution
fnmatch module, Problem, Discussion
fnmatch() function (fnmatch module), Problem, Discussion
fnmatchcase() function (fnmatch module), Problem, Discussion
for loops
consuming iterators manually vs., Problem, Discussion
generators and, Problem, Discussion
fork() function (os module), Discussion
ForkingTCPServer objects (socketserver module), Discussion
ForkingUDPServer objects (socketserver module), Discussion
format() function (built-in )
and non-decimal integers, Solution
floats, specifying precision with, Discussion
formatting output with, Discussion
format() function (built-in), Problem, Discussion
format() method (str type), Solution
customizing string, Problem, Discussion
interpolating variables, Problem, Discussion
__format__() method, Problem, Discussion
format_map() method (str type), Solution
fpectl module, Discussion
fractions module, Problem, Discussion
frame hacking, Discussion
from module import * statement (modules), Problem
reload() function and, Discussion
from module import name, Selectively eliminate attribute access
fromkeys() method (dict type), Solution
from_bytes() method (int type), Solution
fset attribute (properties), Discussion
fsum() function (math module), Discussion
full() method (queue module), Discussion
functions, Functions, Discussion
accepting arbitrary arguments for, Problem, Discussion
accessor functions as attributes of, Problem, Discussion
anonymous/inline, defining, Problem, Discussion
argument annotations, Problem
calling with fewer arguments, Problem, Discussion
closures, accessing variables inside, Problem, Discussion
default arguments for, Problem, Discussion
disassembling, Problem, Discussion
inlining callbacks, Problem, Discussion
keyword arguments only, Problem, Discussion
multiple return values for, Problem
partial() function and, Problem, Discussion
pointers, converting to callables, Problem, Discussion
replacing classes with, Problem, Discussion
state, carrying, Problem, Discussion
wrapper layers for, Problem, Discussion
wrapping with Cython, Problem, Discussion
futures module (concurrent module), Discussion, Problem, Discussion
ProcessPoolExecutor class, Problem, Discussion
FutureWarning argument (warn() function), Solution

G

garbage collection
caching instances and, Discussion
cyclic data structures and, Discussion
gauss() function (random module), Discussion
gdb debugger, Problem, Discussion
General Decimal Arithmetic Specification (IBM), Discussion
generator expressions
concatenating/combining strings and, Discussion
filtering sequence elements with, Solution
flattening nested sequences with, Problem, Discussion
recursive algorithms vs., Problem, Discussion
transforming/reducing data with, Problem, Discussion
Generator Tricks for Systems Programmers (Beazley), Discussion
generator-expression argument, Solution
GeneratorExit exception, Solution
generators, Iterators and Generators, Discussion
concurrency with, Problem, Discussion
creating iterator patterns with, Problem, Discussion
defining with extra states, Problem
inlining callback functions with, Solution
islice() function and, Problem, Discussion
iterator protocol, implementing, Problem, Discussion
pipelines, creating with, Problem, Discussion
search functions and, Discussion
slicing, Problem, Discussion
unpacking, Discussion
GET requests (HTTP), Solution
get() function (webbrowser class), Solution
get() method (ElementTree module), Discussion
get() method (queue module), Solution, Discussion
__get__() method, Problem, Discussion
descriptors, Solution, Discussion
getattr() function, Solution
visitor patterns and, Discussion
__getattr__() method (delegation), Solution, Discussion
getboolean() method (ConfigParser module), Discussion
getdefaultencoding() function (sys module), Solution
getfilesystemencoding() function (sys module), Problem, Discussion
getframe() (sys module), Discussion
frame hacking with, Discussion
__getitem__() method, Discussion
getLogger() function (logging module), Discussion
getpass module, Solution
getpass() method (getpass module), Discussion
getrandbits() function (random module), Solution
getrecursionlimit() function (sys module), Discussion
gettempdir() function (tempfile module), Discussion
getuser() (getpass module), Discussion
get_archive_formats() function (shutil module), Solution
get_data() function (pkgutil module), Discussion
get_terminal_size() function (os module), Discussion, Solution
gevent module, Discussion
glob module, Discussion
Global Interpreter Lock (GIL), Discussion, Problem, Discussion
C, calling Python from, Discussion
C/Python threads, mixing, Problem, Discussion
releasing in C extensions, Problem
releasing in Cython, Discussion
thread pools and, Discussion
grammar rules, for parsers, Problem, Discussion
greenlets, Discussion
.group() method (re module), Solution
groupby() function (itertools module), Problem, Discussion
grouping records, in dictionaries, Discussion
gzip compression format, Discussion
gzip module, Problem, Discussion
compresslevel keyword, Discussion

H

hard limit on resources, Discussion
hashes, Solution
heappop() method (heapq module), Discussion
priority queues and, Solution
heapq module, Problem, Discussion
merge() function, Problem, Discussion
heaps, Problem, Discussion
nlargest()/nsmallest() functions and, Discussion
reversing order of, Discussion
help function
keyword arguments and, Discussion
metadata for arguments and, Problem
hex() function, Problem, Discussion
hexadecimal digits, encoding, Problem, Discussion
hexadecimal integers, Problem, Discussion
hmac module, Problem, Discussion
HTML entities
handling in text, Problem, Discussion
replacing, Solution
html module, Solution
HTTP services
clients, Problem, Discussion
headers, custom, Solution
testing client code, Discussion
httpbin.org service, Discussion

I

I/O, Files and I/O, Discussion
decoding/encoding functions for, Solution
event-driven, Problem, Discussion
iter() function and, Discussion
objects, serializing, Problem, Discussion
operations on strings, Problem, Discussion
passing open files and, Discussion
serial ports, communicating with, Problem, Discussion
thread termination and, Solution
IDEs for Python development, Discussion
__init__() method, data structures and, Discussion
if-elif-else blocks, Discussion
IGNORECASE flag (re module), Solution
ignore_patterns() function (shutil module), Solution
ignore_types argument (isinstance() function), Solution
import hooks, Solution, Solution
patching modules on import, Problem, Discussion
sys.path_hooks variable and, Solution
import statement, Problem, Discussion
ImportError exceptions, Discussion
importlib module, Discussion
import_module() function (importlib module), Problem, Discussion
index-value pairs, iterating over, Problem, Discussion
IndexError exception, Discussion
indexing in CSV files, Problem, Discussion
indices() method (slice), Discussion
infinite values, Problem, Discussion
info() function (logging module), Solution
inheritance
class decorators and, Discussion
class defined decorators and, Discussion
delegation vs., Discussion
implementation of, Discussion
.ini file features, Discussion
__init__() method (classes), Discussion
bypassing, Problem, Discussion
coding conventions and, Problem, Discussion
data structure initialization and, Problem, Discussion
mixins and, Discussion
multiple constructors and, Problem, Discussion
optional arguments and, Discussion
super() function and, Problem, Discussion
inline functions
callbacks, Problem, Discussion
defining, Problem, Discussion
input files, Problem
input() function (fileinput), Discussion
insert() method (ElementTree module), Discussion
inspect() module, Problem, Discussion
instances
cached, metaclasses and, Solution
creation, controlling with metaclasses, Problem, Discussion
descriptors and, Problem, Discussion
saving memory when creating, Problem, Discussion
serializing with JSON, Discussion
WSGI applications as, Discussion
int type, Problem, Discussion
int() function, Solution
interface files (Swig), Solution
interpreters, communication between, Problem, Discussion
invalidate_caches() function (importlib module), Discussion
io module, Problem, Discussion, Problem, Discussion
ioctl(), Problem
IPv4Address objects (ipaddress module), Discussion
is operator, Discussion
isinf() function (math module), Solution
isinstance() function, Solution
islice() function (itertools module), Problem, Discussion, Solution
isnan() function (math module), Solution
issuing warning messages, Discussion
is_alive() method (Thread class), Solution
itemgetter function (operator module), Solution
items() method (dictionaries), Discussion
iter() function
fixed size records and, Problem
while loops vs., Problem, Discussion
__iter__() method (iterators), Problem, Discussion
generators with extra states and, Solution
iterables
custom containers for, Problem, Discussion
discarding parts of, Problem, Discussion
from C, consuming, Problem, Discussion
sorted/merged, iterating over, Problem, Discussion
unpacking, Problem, Discussion
iterating
all possible combinations/permutations, Problem, Discussion
chain() method (itertools module), Problem, Discussion
iter() function vs. while loops, Problem, Discussion
merge() function (heapq module), Problem, Discussion
over fixed-sized records, Problem
over index-value pairs, Problem, Discussion
over separate containers, Problem, Discussion
over sorted/merged iterables, Problem, Discussion
reverse, Problem
zip() function and, Problem, Discussion
iterators, Iterators and Generators, Discussion
consuming manually, Problem, Discussion
creating patterns with generators, Problem, Discussion
delegating, Problem, Discussion
islice() function (itertools module), Problem, Discussion
protocol, implementing, Problem, Discussion
slicing, Problem, Discussion
iterparse() function (ElementTree module), Discussion
iterparse() method (ElementTree module), Discussion
itertools module, Problem, Discussion, Problem, Discussion
compress() function, Discussion
groupby() function, Problem, Discussion
iter_as() function, Solution

J

join() method (str type), Problem, Discussion
changing single characters with, Discussion
join() method (Thread class), Solution
JSON (JavaScript Object Notation)
reading/writing, Problem, Discussion
types supported by, Discussion
json module, Problem, Discussion
just-in-time (JIT) compiling, Problem, Discussion

K

key argument (sorted() function), Solution
KeyboardInterrupt exception, Solution, Discussion
keys() method (dictionaries), Discussion
keyword arguments, Solution
annotations, Problem
for metaclasses, Problem, Discussion
functions that only accept, Problem, Discussion
help function and, Discussion

L

lambda expressions, Discussion, Solution
variables, capturing, Problem, Discussion
launching
Python debugger, Solution
web browsers, Discussion
lazy imports, Discussion
lazy unpacking, Discussion
leap years, datetime module and, Solution
libraries, adding logging to, Problem
limited history, Problem, Discussion
linalg subpackage (NumPy module), Solution
linear algebra, Problem, Discussion
list comprehension, Solution
listdir() function (os module), Problem, Discussion
bad filenames, printing, Problem, Discussion
lists
NumPy vs., Solution
processing and star unpacking, Discussion
unpacking, Discussion
ljust() method (str type), Solution
llvmpy extension module, Discussion
load() function (pickle module), Solution
untrusted data and, Discussion
LoadLibrary() function (ctypes.cdll module), Discussion
loads() function (json module), Solution
loads() function (pickle module), Solution
loadTestsFromModule() method (TestLoader module), Discussion
loadTestsFromTestCase() method (TestCase module), Discussion
local() method (threading module), Problem, Discussion
locale module, Discussion
locals() function and exec() function, Problem, Discussion
Lock objects (threading module), Problem, Discussion
logging
adding to libraries, Problem
adding to simple scripts, Problem
output of, Discussion
test output to file, Problem
logging module, Discussion, Discussion
critical(), Solution
debug(), Solution
error(), Solution
info(), Solution
warning(), Solution
lower() method (str type), Solution
lstrip() method (str type), Solution
lxml module, Discussion

M

MagicMock instances, Discussion
makefile() method (socket module), Discussion
make_archive() function (shutil module), Solution
MANIFEST.in file, Solution
manipulating pathnames, Problem, Discussion
map() operation (ProcessPoolExecutor class), Discussion
Mapping class (collections module), Solution
mappings
class definition order and, Discussion
consolidating multiple, Problem, Discussion
match() method (re module), Solution
search/replace text and, Solution
math() module, Solution
matrix calculations, Problem, Discussion
matrix object (NumPy module), Solution
max() function, Discussion, Discussion
attrgetter() function and, Discussion
generator expressions and, Discussion
itemgetter() function, Discussion
memory
management in cyclic data structures, Problem, Discussion
mapping, Problem, Discussion
OrderedDict objects and, Discussion
parsing XML and, Problem, Discussion
restricting use of, Problem
wchar_t strings and, Discussion
__slots__ attribute and, Problem, Discussion
memory mapping, Problem, Discussion
MemoryError exceptions, Solution
memoryview() object (struct module), Discussion, Solution, Discussion
Cython-typed, Discussion
large arrays and, Problem, Discussion
memory_map() function (mmap module), Solution
merge() function (heapq module), Problem, Discussion
Mersenne Twister algorithm, Discussion
meta path importer, Solution, Solution
sys.metapath object, Solution
metaclass keyword (class statement), Problem, Discussion
metaclasses, Solution
capturing attribute definition order, Problem, Discussion
controlling instance creation, Problem, Discussion
enforcing coding conventions, Problem, Discussion
initializing members at definition time, Problem, Discussion
non-standardized binary files and, Solution
optional arguments for, Problem, Discussion
__prepare__() method and, Discussion
metaprogramming, Metaprogramming, Discussion
adjustable attributes, Problem, Discussion
decorators, Problem, Discussion
decorators with arguments, Problem, Discussion
dis module, Problem, Discussion
exec() function vs., Problem, Discussion
function metadata in decorators, Problem, Discussion
function wrappers, Problem, Discussion
repetitive property methods and, Problem, Discussion
unwrapping decorators, Problem, Discussion
method overloading, Problem, Discussion
methodcaller() function (operator module), Solution
Microsoft Excel, CSV encoding rules of, Discussion
Microsoft Visual Studio, Solution
min() function, Discussion, Discussion
attrgetter() function and, Discussion
generator expressions and, Discussion
itemgetter() function, Discussion
__missing__() method (dict module), Solution
mixin classes, Discussion
extending unrelated classes with, Problem, Discussion
in descriptors of data models, Discussion
mkdtemp() function (tempfile module), Discussion
mkstemp() function (tempfile module), Discussion
mmap module, Problem, Discussion
mock module (unittest module), Solution, Discussion
module import * statement, Problem, Discussion
modules, Modules and Packages, Discussion
controlling import of, Problem, Discussion
from module import * statement, Problem
hierarchical packages of, Problem, Discussion
import hooks, using, Problem, Discussion
importing with relative names, Problem, Discussion
importing, using string as name, Problem
importlib module, Discussion
import_module() function (importlib module), Problem
invalidate_caches() function (importlib module), Discussion
meta path importer, Solution, Solution
new_module() function (imp module), Discussion
objects, creating, Discussion
patching on import, Problem, Discussion
relative imports vs. absolute names, Discussion
reloading, Problem, Discussion
remote machines, loading from, Problem, Discussion
splitting into multiple files, Problem, Discussion
sys.path, adding directories to, Problem, Discussion
sys.path_importer_cache object, Discussion
virtual environments and, Problem, Discussion
__all__ variable in, Problem, Discussion
__init__.py file, Problem
__main__.py files, Problem, Discussion
monthrange() function (calendar module), Discussion
months, finding date ranges of, Problem, Discussion
moving directories/files, Problem
__mro__ attribute, Discussion
multidicts, Problem, Discussion
multiple-dispatch, Problem, Discussion
multiprocessing module, Discussion
GIL and, Solution
passing file descriptors with, Problem, Discussion
reduction module, Problem, Discussion
RPCs and, Solution
mutable buffers, reading into, Problem, Discussion
MutableMapping class (collections module), Solution
MutableSequence class (collections module), Solution
MutableSet class (collections module), Solution

N

named pipes (Windows), Discussion, Solution, Discussion
NamedTemporaryFile() function (tempfile module), Discussion
namedtuple() function (collections module), Solution
namedtuple() method (collections module)
new_class() function and, Discussion
unpacking binary data and, Discussion
NameError exception, Solution
namespace package, checking for, Discussion
namespaces (XML), parsing, Problem, Discussion
namespaces, multiple directories in, Problem, Discussion
naming conventions
for private data, Problem, Discussion
__ (double underscore) and, Solution
NaN (not a number) values, Problem, Discussion
in JSON, Discussion
isnan() function and, Discussion
nested sequences, flattening, Problem, Discussion
network programming, Network and Web Programming, Discussion
connection (multiprocessing module), Problem, Discussion
event-driven I/O, Problem, Discussion
hmac module, Problem, Discussion
interpreters, communication between, Problem, Discussion
large arrays, sending/receiving, Problem, Discussion
passing file descriptors, Problem, Discussion
remote procedure calls, Problem, Discussion, Problem, Discussion
simple authentication, Problem, Discussion
socketserver module, Problem, Discussion
SSL, implementing, Problem, Discussion
TCP servers, Problem, Discussion
UDP server, implementing, Problem, Discussion
UDPServer class, Discussion
XML-RPC, Problem, Discussion
__new__() method (classes)
coding conventions and, Problem, Discussion
optional arguments and, Discussion
newlines, Discussion
new_class() function (types module), Problem, Discussion
new_module() function (imp module), Discussion
next() function (iterators), Solution
nlargest() function (heapq module), Problem, Discussion
nonblocking, supporting with queues, Discussion
noncapture groups (regular expressions), Solution
nonlocal declarations, Discussion
adjusting decorators with, Problem, Discussion
normalize() function (unicodedata module), Solution, Solution
normalize() method (pytz module), Solution
normalizing Unicode, Problem, Discussion
supported forms in Python, Solution
normpath() (os.path module), Discussion
nsmallest() function (heapq module), Problem, Discussion
null-terminated strings, passing to C, Problem, Discussion
NullHandler() class (logging module), Discussion
numerical operations, Numbers, Dates, and Times, Discussion
complex-valued math, Problem, Discussion
decimal calculations, Problem, Discussion
formating for output, Problem, Discussion
infinity and, Problem, Discussion
linear algebra calculations, Problem, Discussion
matrix calculations, Problem, Discussion
NaNs and, Problem, Discussion
NumPy and, Problem, Discussion
on fractions, Problem, Discussion
packing/unpacking integers from byte string, Problem, Discussion
random number generators, Problem, Discussion
rounding, Problem, Discussion
time, Problem, Discussion
time conversions, Problem, Discussion
with binary integers, Problem, Discussion
with hexadecimal integers, Problem, Discussion
with octal integers, Problem, Discussion
NumPy module, Problem, Discussion, Discussion
complex math and, Discussion
CPU-bound programs and, Solution
linear algebra and, Problem, Discussion
matrix calculations and, Problem, Discussion
unpacking binary data with, Discussion

O

objects, Classes and Objects, Discussion
and context-management protocols, Problem, Discussion
calling methods on, when named in strings, Problem, Discussion
creating large numbers of, Problem, Discussion
defining default arguments and, Discussion
format() function and, Problem, Discussion
formatting output of, Problem, Discussion
implementing states for, Problem, Discussion
iterator protocol, implementing, Problem, Discussion
JSON dictionary, decoding to, Discussion
memory management, Problem, Discussion
representing in C, Discussion
serializing, Problem, Discussion
visitor pattern, implementing, Problem, Discussion
visitor patterns without recursion, Problem, Discussion
with statement and, Problem, Discussion
object_hook (json.loads() function), Discussion
object_pairs_hook (json.loads() function), Discussion
oct() function, Problem, Discussion
octal integers, Problem, Discussion
Olson time zone database, Solution
opaque pointers, Problem, Discussion
open() function, Problem, Discussion
binary data, reading/writing, Problem, Discussion
closefd argument, Solution
file descriptors and, Solution
on non-Unix systems, Discussion
rb/wb modes of, Problem, Discussion
rt/wt mode, Problem, Discussion
x mode of, Problem, Discussion
optimizating your programs, Problem
optparse vs. argparse, Discussion
OrderedDict object (collections module), Problem, Discussion
decoding JSON data into, Discussion
os module
listdir() function, Problem, Discussion
path module in, Problem, Discussion
OSError exception, Solution, Discussion
ouput sent to stdout, Testing, Debugging, and Exceptions

P

pack() function (structs), Discussion
packages, Modules and Packages, Discussion
datafiles, reading, Problem, Discussion
directories/zip files, running, Problem, Discussion
distributing, Problem, Discussion
hierarchical, of modules, Problem, Discussion
MANIFEST.in file, Solution
namespaces, multiple directories in, Problem, Discussion
per-user directory, installing, Problem, Discussion
submodules, importing with relative names, Problem, Discussion
sys.path, adding directories to, Problem, Discussion
third-party options for, Discussion
virtual environments and, Problem, Discussion
__init__.py file, Problem
__path__ variable and, Discussion
pack_into() function (struct module), Discussion
Pandas package, Discussion, Problem, Discussion
parallel programming, Problem, Discussion
parse tree, Solution
parse() function (ElementTree module), Discussion
parser (html), Discussion
parser, recursive descent, Problem, Discussion
parse_and_remove() function (ElementTree module), Discussion
parsing command-line options, Utility Scripting and System Administration, Problem
partial() function (functools module), Problem, Discussion
defining property methods and, Discussion
fixed size records and, Problem
optional arguments for decorators and, Discussion
state, carrying with, Solution, Discussion
Paste, Discussion
patch() function (unittest.mock class)
testing output with, Solution
unit tests with, Problem
patching objects, Problem
path module (os), Problem, Discussion
testing for existing files with, Problem, Discussion
pathnames, manipulating, Problem, Discussion
pattern matching, Problem, Discussion
pattern object (regular expressions), Solution
pdb debugger, Problem, Discussion
per-user directory, Problem, Discussion
performance
ast manipulation and, Discussion
attrgetter() function and, Discussion
Cython and, Problem, Discussion
dictionary comprehension vs. dict() type, Discussion
join() method vs. + operator, Discussion
keeping limited history and, Discussion
lazy attributes and, Problem, Discussion
nlargest()/nsmallest() functions and, Discussion
NumPy module and, Problem, Discussion
of byte vs. text strings, Discussion
pattern objects and, Discussion
profiling/timing, Problem
sanitizing strings and, Discussion
strptime() method and, Discussion
perf_counter() function (time class), Discussion, Discussion
PermissionError exception, Solution
permutations() function (itertools module), Solution
pexpect, Problem
pickle module, Problem, Discussion
limits on, Discussion
multiprocessing.connection functions and, Solution
RPCs and, Problem, Discussion
Pipe object (multiprocessing module), Solution
pipelines, creating, Problem, Discussion
pipes
accepting script via, Problem
mimicking, Problem, Discussion
PLY, Discussion, Discussion
polling thread queues, Problem, Discussion
Popen class (subprocess module), Discussion
POST method (HTTP), Solution
pprint() function (pprint module), Discussion
predefined abstract base classes, Discussion
prefix variable, Discussion, Discussion
__prepare__() method (classes), Discussion
new_class() function and, Solution
optional arguments and, Discussion
prepare_class() function (types module), Discussion
print() function, Solution, Solution, Solution
end argument, Solution
line ending, changing, Problem, Discussion
redirecting to files, Problem
separator character, changing, Problem, Discussion
private data/methods
caching instances within, Discussion
naming conventions for, Problem, Discussion
probability distributions (random module), Discussion
process pools, GIL and, Solution, Discussion
ProcessPoolExecutor class (futures module), Problem, Discussion
process_time() function (time class), Discussion, Discussion
program crashes, debugging, Discussion
program profiling, Problem
property attributes (classes)
delegating, Problem, Discussion
extending in subclasses, Problem, Discussion
repetitive definitions for, Problem, Discussion
@property decorator, Discussion, Discussion
proxies, delegating attributes with, Solution, Discussion
public-facing services, Discussion
put() method (queue module), Solution, Discussion
pwd module, Discussion
PyArg_ParseTuple() function (C extensions), Discussion
converting string encoding with, Discussion
PyBuffer_GetBuffer() method (Py_buffer object), Discussion
PyBuffer_Release() method (Py_buffer object), Discussion
PyCallable_Check() function (C extensions), Discussion
PyCapsule_GetPointer() function (C extensions), Discussion
PyCapsule_Import() function (C extensions), Discussion
PyCapsule_New() function (C extensions), Discussion
PyCapsule_SetDestructor() function (C extensions), Discussion
PyErr_Occurred() function (C extensions), Discussion
PyFile_FromFd() function (C extensions), Problem, Discussion
PyFloat_AsDouble() function (C extensions), Discussion
PyFloat_Check() function (C extensions), Discussion
PyGILState_Ensure() function (C extensions), Discussion, Solution
PyGILState_Release() function (C extensions), Discussion, Solution
PyIter_Next() function (C extensions), Problem, Discussion
PyObject data type (C extension)
filenames, passing with, Problem, Discussion
PyObject_BuildValue function (C extensions), Discussion
PyObject_Call() function (C extensions), Discussion
file-like objects and, Discussion
PyObject_GetIter() function (C extensions), Problem, Discussion
PyParsing, Discussion, Discussion
PyPy, Solution
PySequence_Length() function (C extensions), Discussion
pySerial package, Problem, Discussion
Python for Data Analysis (McKinney), Discussion
Python Package Index, Solution
Python syntax vs. JSON, Discussion
PYTHONPATH environment variable, Solution
pytz module, Problem, Discussion
PyUnicode_FromWideChar() function (C extensions)
C strings, converting to Python objects, Problem, Discussion
pyvenv command, Problem, Discussion
Py_BEGIN_ALLOW_THREADS (Py objects), Problem
Py_BuildValue() function (C extensions), Discussion
C strings, converting to Python objects, Problem, Discussion
Py_DECREF() function (C extensions), Discussion
Py_END_ALLOW_THREADS (Py objects), Problem
Py_XDECREF() function (C extensions), Discussion

Q

qsize() method (queue module), Discussion
queue module, Problem, Discussion
queues
bounding, Discussion
structures, deque() and, Discussion
quote() function (shlex class), Solution

R

race conditions, avoiding, Problem, Discussion
raise from statement, Solution, Discussion
None modifier, Solution
raise statement, Solution, Solution
randint() function (random module), Solution
random module, Problem, Discussion
random() function (random module), Solution
re module
compile() function, Discussion
DOTALL flag, Discussion
IGNORECASE flag, Solution
pattern matching and, Solution, Discussion
patterns, naming, Solution
scanner() method, Solution
search/replace text and, Problem, Discussion
split() method, Problem, Discussion
sub() function, Solution
Unicode text and, Problem, Discussion
read() function, Discussion
file-like C objects and, Problem, Discussion
readability, naming slices for, Problem, Discussion
readinto() method (files), Discussion
reading into mutable buffers with, Problem, Discussion
recursion, Discussion
getrecursionlimit() function (sys module), Discussion
recursive descent parsers, Problem, Discussion
limitations on, Discussion
recvfrom() method (socket module), Discussion
recv_handle() function (reduction module), Problem, Discussion
recv_into() function (socket module), Discussion, Discussion
redirection, Problem
regex module, Discussion
register() function (atexit module), Discussion
register_function() method (XML-RPC), Discussion
regular expressions
* (star) operator and, Solution
? (question mark) modifier and, Solution
greedy vs. nongreedy, Problem, Discussion
matching multiple lines, Problem, Discussion
newline support in, Problem, Discussion
on byte strings, Solution
order of tokens in, Discussion
pattern matching and, Solution, Discussion
re.split() method and, Discussion
regex module for, Discussion
shortest match with, Problem, Discussion
stripping characters with, Discussion
Unicode and, Problem, Discussion
relational databases, Problem, Discussion
connecting to, Solution
cursors, creating, Solution
relative imports vs. absolute names (modules), Discussion
relativedelta() function (dateutil module), Discussion
reload() function (imp module), Problem, Discussion, Discussion
remote machines
loading modules from, Problem, Discussion
XML-RPC, Problem, Discussion
remote procedure calls (RPC), Problem, Discussion
exception handling with, Discussion
remove() method (ElementTree module), Discussion
replace() method (date module), Discussion
replace() method (datetime module), Discussion
_replace() method (namedtuple object), Discussion
replace() method (str type), Discussion, Solution
performance and, Discussion
search/replace text and, Solution
repr() function (built-in), Solution
request module (urllib module), Solution, Discussion
client package vs., Discussion
requests package (urllib module)
return values of, Solution
reraising exceptions, Problem
reserved words, clashing with, Discussion
resource forks, Discussion
resource management, Discussion
resource module, Solution
ResourceWarning argument (warn() function), Solution
REST-base interface, Problem, Discussion
testing, Solution
restricting CPU time, Solution
result() method (ProcessPoolExecutor class), Discussion
reverse iteration, Problem, Discussion
reversed() function, Problem, Discussion
rjust() method (str type), Solution
RLock objects (threading module), Discussion
round() function, Problem, Discussion
rounding numbers, Problem, Discussion
RSS feeds, parsing, Solution
rstrip() method (str type), Solution
RTS-CTS handshaking, Discussion
RuntimeWarning argument (warn() function), Solution

S

sample() function (random module), Solution
sanitizing text, Problem, Discussion
scanner() method (re module), Solution
search
for shortest match with regular expressions, Problem, Discussion
matching multiple lines, Problem, Discussion
nlargest()/nsmallest() functions (heapq module), Problem, Discussion
noncapture groups, Solution
normalization of Unicode text and, Discussion
visitor pattern and, Solution
search/replace text, Problem, Discussion
case insensitive, Problem, Discussion
security
import statement and, Solution
pickle and, Discussion
RPCs and, Discussion
SSL certificates and, Solution
seed() function (random module), Discussion
segmentation faults, Problem, Discussion
select() function (event driven I/O), Solution
self-signed certificates (SSL), Discussion
Semaphore objects (threading module), Discussion, Discussion
send() function (socket module), Discussion
send() method (generators), Discussion
sendmsg() method (socket module), Discussion
sendto() method (socket module), Discussion
send_handle() function (reduction module), Problem, Discussion
Sequence class (collections module), Solution
sequences
filtering elements of, Problem, Discussion
flattening nested, Problem, Discussion
iterating over multiple, simultaneously, Problem, Discussion
mapping names to elements of, Problem, Discussion
most frequently occurring item in, Problem, Discussion
removing duplicates from, Problem, Discussion
unpacking, Problem, Discussion
serial ports, communicating with, Problem, Discussion
serve_forever() method (XML-RPC), Discussion
Set class (collections module), Solution
__set__() method (descriptors), Solution
in data models, Discussion
setattr() method, Discussion
__setattr__() method (delegation), Discussion
setrlimit() function, Discussion
setsid() function (os module), Discussion
setup.py file, Solution, Solution
distributing packages and, Solution
set_trace() function (pdb module), Solution, Discussion
shell, Solution
shell scripts, Utility Scripting and System Administration
shelling out, Problem
shuffle() function (random module), Solution
shutil module
archives and, Problem
copying files/directories with, Solution
sig module, Discussion, Discussion
signature objects, Problem, Discussion
signature() function (inspect), Discussion
SIGXCPU signal, Solution
simple scripts, Problem
simplefilter() function (warnings class), Discussion
SimpleXMLRPCServer (XML-RPC), Discussion
site-packages directories, Solution
virtual environments vs., Problem, Discussion
skip() decorator, Discussion
skipIf() function (unittest module), Discussion
skipping test failures, Problem
skipUnless() function (unittest module), Discussion
slice() object, Discussion
slices, naming, Problem, Discussion
__slots__ attribute
classes with, Discussion
memory management and, Solution
socket module, Discussion
ipaddress module and, Discussion
sending datagrams with, Discussion
socketpair() function (Unix), Solution
sockets
large arrays, sending/receiving, Discussion
setting options on, Discussion
threads and, Solution
socketserver module
implementing TCP servers with, Problem, Discussion
UDP server, implementing, Problem, Discussion
sorted() function
and objects without comparison support, Problem, Discussion
itemgetter() function, Discussion
sorting
dictionaries, Problem, Discussion
dictionaries by common key, Problem, Discussion
finding largest/smallest N items, Problem, Discussion
groupby() function and, Discussion
itemgetter function (operator module), Solution
objects without comparison support, Problem, Discussion
sort_keys argument (json.dumps() function), Discussion
source file vs. config file, Discussion
special characters, escaping, Discussion
split() method (re object), Problem, Discussion
split() method (str type), Problem, Discussion
SQLAlchemy, Discussion
sqlite3 module, Solution
sqrt() function (math module), Selectively eliminate attribute access
ssh session, Discussion
SSL, Problem, Discussion
certificate authorities, Discussion
self-signed certificates, Discussion
ssl module, Problem, Discussion
random module vs., Discussion
Stackless Python, Discussion
stack_size() function (threading module), Discussion
star expressions
discarding values from, Discussion
unpacking iterables and, Solution
start attribute (slice), Discussion
start() method (Thread class), Solution
startswith() method (str type), Solution
pattern matching with, Solution
start_response argument (WSGI), Discussion
state
capturing with closures, Solution, Discussion
carrying with callback functions, Problem, Discussion
implementing for objects/machines, Problem, Discussion
of mixins, Discussion
thread-specific, storing, Problem, Discussion
states, generators with extra, Problem, Discussion
static methods, applying decorators to, Problem, Discussion
@staticmethod decorator, Discussion
decorating class methods with, Problem, Discussion
__func__ attribute and, Discussion
stdout object (sys), changing encoding on, Solution
step attribute (slice), Discussion
stop attribute (slice), Discussion
StopIteration exception, Solution
str type
converting to datetime objects, Problem, Discussion
decode() method, Solution
encode() method, Solution
endswith() method, Solution
format() function, Solution
join() method, Problem, Discussion
lower() method, Solution
pattern matching with, Solution
replace() method, Solution
sanitizing text with, Problem, Discussion
split() method, Problem, Discussion
startswith() method, Solution
stripping unwanted characters from, Problem, Discussion
translate() method, Solution
upper() method, Solution
str() function, Solution
StreamRequestHandler (socketserver module), Solution, Discussion
string module, Discussion
string templates and code readability, Discussion
StringIO object (io module), Discussion
StringIO() object (io module), Problem, Discussion
strings, Strings and Text, Discussion
aligning, Problem, Discussion
bad encoding in C/Python extensions, Problem, Discussion
C, converting to Python objects, Problem, Discussion
calling object methods when named in, Problem, Discussion
combining, Problem, Discussion
concatenating, Problem, Discussion
converting to dates/times, Problem, Discussion
database API and, Discussion
I/O operations, performing on, Problem, Discussion
interpolating variables in, Problem, Discussion
matching start/end text of, Problem, Discussion
null-terminated, passing to C, Problem, Discussion
splitting on delimiters, Problem, Discussion
stripping unwanted characters from, Problem, Discussion
Unicode, passing to C modules, Problem, Discussion
unpacking, Discussion
strip() method (str type), Problem, Discussion
strptime() method (datetime module), Discussion
struct module, Problem, Discussion
nested binary records, reading, Problem, Discussion
packing/unpacking integers from byte strings and, Discussion
structure codes for, Discussion
variable-sized binary records, reading, Problem, Discussion
structures (data type), Problem, Discussion
sub() function (re module), Solution, Discussion
search/replace text and, Solution
submit() operation (ProcessPoolExecutor class), Discussion
subn() method (re module), Solution
subprocess module, Discussion
subsitution callback functions, Solution
super() function, Problem, Discussion
class decorators and, Discussion
coding conventions and, Discussion
extending properties in subclasses and, Discussion
mixin classes and, Discussion
surrogate encoding, Problem, Discussion
Swig, Discussion, Problem, Discussion
headers and, Discussion
symbolic links, Solution
broken, Discussion
SyntaxWarning argument (warn() function), Solution
sys.arg value, Discussion
sys.argv (commaand line arguments), Discussion
sys.metapath object, Solution, Discussion
extending import operations and, Discussion
sys.modules dictionary, Discussion
sys.path
adding directories to, Problem, Discussion
site-packages directories, Solution
sys.path_hooks variable (importers), Solution
sys.path_importer_cache object, Discussion
sys.stderr, Solution
sys.stdout, Problem, Discussion
system-exiting exceptions, Discussion
SystemExit exception, Solution, Solution, Discussion

T

tag attribute (ElementTree module), Discussion
tarfile compression format, Discussion
TCP servers, Problem, Discussion
event-driven I/O implementation, Solution
tempfile module, Problem, Discussion
temporary files, Problem, Discussion
TemporaryDirectory() method (tempfile module), Solution
TemporaryFile (tempfile module), Solution
terminal, finding size of, Discussion, Problem
test failures, Problem
TestCase classes (TestLoader module), Discussion
testing
ouput sent to stdout, Testing, Debugging, and Exceptions
output, logging to file, Problem
unit tests for exceptions, Problem
TestLoader class (unitest module), Discussion
text attribute (ElementTree module), Discussion
text data
encoding, Problem, Discussion
reading/writing, Problem, Discussion
text manipulation, Strings and Text, Discussion
aligning strings, Problem, Discussion
case insensitive search/replace, Problem, Discussion
combining/concatenating, Problem, Discussion
HTML entities, handling in text, Problem, Discussion
interpolating variables, Problem, Discussion
matching start/end of strings, Problem, Discussion
of Unicode with regular expressions, Problem, Discussion
on byte strings, Problem, Discussion
parsers, implementing, Problem, Discussion
pattern matching, Problem, Discussion
reformatting into columns, Problem, Discussion
sanitizing, Problem, Discussion
search/replace, Problem, Discussion
stripping unwanted characters, Problem, Discussion
tokenizing, Problem, Discussion
wildcard matcing, Problem, Discussion
XML entities, handling in text, Problem, Discussion
TextIOWrapper object (io module), Problem, Discussion
textwrap module, Problem, Discussion
Thread class (threading module), Problem, Discussion
thread pools
GIL and, Discussion
queues and, Solution
threading module, Discussion
Condition object, Discussion
Event object, Problem, Discussion
local() method, Problem, Discussion
Lock objects, Problem, Discussion
Semaphore objects, Discussion
stack_size() function, Discussion
ThreadingMixIn class (socketserver module), Discussion
ThreadingTCPServer objects (socketserver module), Discussion
ThreadingUDPServer objects (socketserver module), Discussion
ThreadPoolExecutor class (futures module), Problem, Discussion
threads
actor model and, Problem, Discussion
C/Python, mixing, Problem, Discussion
communication between, Problem, Discussion
creating/destroying, Problem, Discussion
daemonic, Solution
deadlocks between, Problem, Discussion
generators as alternative to, Problem, Discussion
locking critical sections, Problem, Discussion
nonblocking, supporting with queues, Discussion
polling multiple queues, Problem, Discussion
pools of, Problem, Discussion
priority queues and, Discussion
queue module and, Problem, Discussion
race conditions, avoiding, Problem, Discussion
status of, finding, Problem, Discussion
storing state of, Problem, Discussion
timeouts, supporting with queues, Discussion
throw() method (generators), Discussion
time command, Solution
time module, Discussion
time zones, Problem, Discussion
country_timezones dictionary (pytz module), Discussion
UTC time, Discussion
time() function (time class), Discussion
time, operations on, Problem, Discussion
converting strings for, Problem, Discussion
date calculations, Problem, Discussion
date ranges, finding, Problem, Discussion
pytz module, Problem, Discussion
time conversions, Problem, Discussion
time zones, manipulating, Problem, Discussion
UTC time, Discussion
timedelta object (datetime module), Solution, Discussion, Discussion
timeit module, Solution, Discussion
timeouts, supporting with queues, Discussion
Timer class, Discussion
tokenizing and DOTALL flag (re module), Discussion
tokens streams, filtering, Solution
tostring() function (ElementTree module), Solution
total_ordering decorator (functools module), Problem, Discussion
to_bytes() method (int module), Solution
traceback, segmentation faults and, Problem, Discussion
traceback.print_stack() function, Solution
translate() method (str type), Discussion, Solution
numerical output and, Discussion
performance and, Discussion
transmitting data, Discussion
tree structures, memory management of, Problem, Discussion
tree traversal, Solution, Discussion
TTYs, Problem, Discussion
tuples
and endswith()/startswith() methods, Solution
as return values, Problem
relational databases and, Problem, Discussion
unpacking, Discussion
Twisted package, Discussion
type checking (data)
abstract base classes and, Problem, Discussion
forcing with decorator functions, Problem, Discussion
type systems, Problem, Discussion
%typemap directive (Swig), Discussion
types module, Problem, Discussion

U

UDP server, Problem, Discussion
event-driven I/O implementation, Solution
UDPServer class, Discussion
umask() function (os module), Discussion
unescape() function (xml.sax.saxutils module), Discussion
Unicode, Problem, Discussion
bad encoding in C/Python extensions, Problem, Discussion
IGNORECASE flag and matching, Discussion
regular expressions and, Problem, Discussion
strings, passing to C modules, Problem, Discussion
unicodedata module, Solution
uniform() function (random module), Discussion
unittest module, Testing, Debugging, and Exceptions, Discussion, Discussion
Unix, Discussion
commands, Solution
find utility, Discussion
unpack() function (struct module), Discussion
binary data and, Solution
unpacking
archives, Problem
discarding values while, Discussion
enumerate() function and, Discussion
integers from byte string, Problem, Discussion
iterables into separate variables, Problem, Discussion
iterables of arbitrary length, Problem, Discussion
sequences into separate variables, Problem, Discussion
star expressions and, Solution
unpack_archive() function (shutil module), Solution
unpack_from() method (struct module), Discussion
uploading using requests module, Solution
upper() method (str type), Solution
urllib module, Solution, Problem, Discussion
urlopen() function (urllib module), Discussion, Discussion
import statements vs., Solution
sending query parameters with, Solution
UserWarning argument (warn() function), Solution
UTC time, Discussion

V

validation of data, abstract base classes and, Problem, Discussion
ValueError, Solution
unpacking and, Solution
values() method (dictionaries), Discussion, Discussion
variables
interpolating, in strings, Problem, Discussion
understand locality of, Selectively eliminate attribute access
vars() method, Solution
virtual environments, Problem, Discussion
visitor pattern
implementing with recursion, Problem, Discussion
implementing without recursion, Problem, Discussion

W

walk() function (os module), Solution
warn() function (warning class), Solution
warning messages, issuing, Discussion
warning module, Discussion
warning() function (logging module), Solution
watchdog timers, Discussion
wchar_t * declarations (C), Problem, Discussion
converting to Python objects, Solution
weak references and caching instances, Discussion
weakref module, Solution, Discussion
web browsers, launching, Discussion
web programming, Network and Web Programming, Discussion
HTTP service clients, Problem, Discussion
REST-base interface, Problem, Discussion
urllib module and, Problem, Discussion
webbrowser module, Solution
WebOb, Discussion
while loops vs. iter() function, Problem, Discussion
wildcard matcing, strings, Problem, Discussion
Windows, Discussion
C extension modules and, Solution
with nogil: statement (Cython), Discussion
with statement, Problem, Discussion, Discussion, Discussion
contextmanager decorator and, Discussion
Lock objects and, Problem, Discussion
Semaphore objects and, Discussion
wraparound() decorator (Cython), Discussion
__wrapped__ attribute, Discussion
@wraps decorator (functools)
function metadata and, Problem, Discussion
unwrapping, Problem, Discussion
WSGI standard, Problem, Discussion
return value for apps based on, Discussion

X

XML entities
handling in text, Problem, Discussion
replacing, Solution
XML files
dictionaries, converting to, Problem, Discussion
extracting data from, Problem, Discussion
modifying, Problem, Discussion
parsing, Problem, Discussion
incrementally, Problem, Discussion
with namespaces, Problem, Discussion
rewriting, Problem, Discussion
tags, specifying, Discussion
XML-RPC, Problem, Discussion
adding SSL to, Solution
data types handled by, Discussion
xml.etree.ElementTree module (see ElementTree module)
xml.sax.saxutils module, Discussion
XMLNamespaces class, Discussion

Y

yield from statement, Problem, Discussion
yield statement, Discussion, Discussion
behavior in generators, Discussion
concurrency implementations and, Problem, Discussion
generators and, Discussion
search functions and, Discussion

Z

ZeroMQ, Discussion
zip files as runnable scripts, Problem, Discussion
zip() method (dictionaries), Problem, Discussion, Problem, Discussion
zipfile compression format, Discussion