12.07.2015 Views

Is Python a

Is Python a

Is Python a

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

ord function, 355pow function, 353random module, 107range function, 221, 249, 265, 268raw_input function, 211, 233, 621repr function, 96, 101round function, 106scopes, 313, 314set function, 87, 108sorted function, 82, 263, 264, 292, 366str function, 96, 101strings (see strings)sum function, 263, 366sys module, 229sys.path list, 392, 430tools, 15, 95True name, 109tuple function, 175, 264, 329tuples (see tuples)type function, 305types and iterators, 364zip function, 265, 268byte code, 7compiling, 25CC++ language, 10, 15C, integration with, 15_ _call_ _ method, 492, 502callbacks, 349, 536handlers, 346call-by-reference, 329calling methods, 485, 486calls, 202, 299embedding, 56intercepting, 502case sensitivity, 225categories, class-based, 627characters, encoding large sets, 130chr function, 355_ _class_ _ attribute, 509class methods, 549, 552–556using, 554–556versus instance methods, 555class properties, 550–552class statements, 203, 451, 466, 481–484compared to functions, 482compared to names in a module, 482data attributes, 482defs, 483example, 482–484general form, 481inheritance, 483multiple inheritance, 529namespaces, 482statements nested in, 482class-based categories, 627class-based exceptions, 604–613built-in, 609example, 604–605sending extra data and behavior ininstances, 611–613specifying exception text, 610versus string-based exceptions, 604why, 606–609classes, 454, 455as records, 519–521assignments inside class statements, 466attributes, 466, 487coding basics (see coding basics)coding class trees, 456–459coding details, 481–517class statements (see class statements)example, 512–515inheritance (see inheritance)methods (see methods)namespaces (see namespaces)operator overloading (see operatoroverloading)derived from built-in types, 546designing with, 518–538overloading by call signatures, 519extending built-in types, 539–543by embedding, 540by subclassing, 540–543gotchas, 559–564changing attributes, 559–560methods, classes, and nestedscopes, 561–563multiple inheritance, 560–561overwrapping, 563intercepting <strong>Python</strong> operators, 472–476example, 474–475interface techniques, 489method calls, 456mix-in, 529modules, 471new-style, 545–552_ _getattribute_ _ method, 552_ _slots_ _ class attribute, 549diamond inheritance change, 546–549other extension, 549–552properties, 550–552static and class methods, 549Index | 683

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!