functions, 796 single quotes (') and strings, 158 site module, 537 slice assignment in lists, 202 slice objects, 168 slicing, 81, 165, 166 example, 168 extended slicing, 167 loops, usage in, 343 software components, 653 sort method, 87, 203, 388, 454 sorted function, 93, 363 sorts in Python 3.0, 204 source code, 26 source file character set encoding declarations, 912 spaces, 314 special characters, 897 split method, 235 square brackets [ ], 78, 108, 269 dictionaries and, 209 list comprehensions and, 359, 486, 504 lists and, 89, 199 square roots, 126 stack trace, 828, 840 Stackless Python, 33 standard library, 4, 533 library directories, 537 standard manual set, 386 standard output stream (stdout), 297 state information, 102, 644 state retention, 429–432, 727, 997–1000 state with classes, 430 statements, 75, 261–276 assignment statements (see assignment statements) compound statements, 264 differences from other C-like languages, 265 end-of-line, 265 expression statements, 295 in-place changes, 296 indentation syntax, 266 multiline statements, 317 Python 3.0 statement set, 262 syntax, 264 block rule special case, 270 colon (:), 264 indentation, 266 interactive loops, 271–276 semicolons, 269 statement separators, 269 static methods, 686, 795–801 alternatives to, 798 coding with decorator syntax, 804 counting instances, 800 Python 2.6 and 3.0, 796 using, 799 staticmethod function, 799 steps, 167 StopIteration exception, 352 str, 79, 157, 169 repr, compared to, 116 str object type data encoding in, 901 str string type, 899 Python 2.6 operation set, 911 Python 3.0 compared to 2.x, 899 Unicode and, 85 stream processors, 742 stream redirection, 44 strides, 167 string exceptions, 859 deprecation of, 858 string formatting, 179–183 advanced expressions, 181 dictionary-based formatting expressions, 182 string formatting type codes, 181 string formatting method calls, 183–193 format method, 184–193 % formatting expression, compared to, 187 justification for, 190 keys, attributes, and offsets, 184 string methods, 172–179 additional examples, 177 changing strings example, 174 parsing text example, 176 Python 2.x string module, 178 string method calls to format method, 185 string method calls, Python 3.0, 173 string object type, 80–86, 155–163 coding special characters, 85 pattern matching, 85 raw string literals, 85 Index | 1157