12.07.2015 Views

Is Python a

Is Python a

Is Python a

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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

end of line, 204enumerate function, 271enumerated data types, 221env lookup, 42environment, 642environment variable settings, 642_ _eq_ _ method, 492equality, 186–189error checks, 599error handling, 576testing inputs, 212escape sequences, suppressing, 127eval built-in, 27eval function, 105, 338using eval to convert from strings toobjects, 180event handlers, registering functionsas, 503–505event notification, 577except clauses, 582except, empty, 584exception (built-in exception), 609exception objects, 602–616class-based exceptions, 604–613built-in, 609example, 604–605sending extra data and behavior ininstances, 611–613specifying exception text, 610versus string-based exceptions, 604why, 606–609string-based exceptions, 603versus class-based exceptions, 604exceptions, 575–601, 630assert (see assert statement)built-inArithmeticError, 609AssertionError, 595catching, 586exception, 609KeyError, 614OverflowError, 609StandardError, 609catching built-in, 586class-based, 602default behavior, 585default exception handler, 578design tips, 624–627avoiding empty excepts, 625–627using class-based categories, 627what should be wrapped, 624designing with, 617–629empty except, 584error handling, 576event notification, 577example, 577–581gotchas, 627–629catching wrong thing, 629string exceptions match by identity,not value, 628–629handler, 578how they have changed, 575idioms, 621–624debugging with outer trystatements, 622exceptions are not always errors, 621functions signal conditions withraise, 622running in-process tests, 623sys.exc_info, 624IndexError, 578nesting exception handlers, 617–621control-flow nesting, 619syntactic nesting, 619–621NotImplementedError, 490objects (see exception objects)propagating with raise, 594<strong>Python</strong> 3.0, 584raise (see raise statement)raising and catching user-defined, 593special-case handling, 577termination actions, 577trapping constraints, 595try/except (see try/except)try/except/else (see try/except/else)try/finally (see try/finally)unusual control flows, 577user-defined, 579why use, 576–577with/as (see with/as)excepts, avoiding empty, 625–627exec built-in, 27exec statement, 203execfile('module.py') built-in function, 50executionPVM, 26execution models, future possibilities, 32exercisessolutions, 646–680Part I - Breaks, 647Part I - Errors, 647Part I - Interaction, 646686 | Index

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

Saved successfully!

Ooh no, something went wrong!