Skip to Content
Python Pocket Reference
book

Python Pocket Reference

by Mark Lutz
November 1998
Beginner
80 pages
1h 14m
English
O'Reilly Media, Inc.
Content preview from Python Pocket Reference

Built-in Exceptions

Exceptions which Python may raise during a program’s execution. Beginning with Python 1.5, all built-in exceptions are classes. Prior to 1.5, they were strings; to force string exceptions for backward compatibility, use the -X command-line option flag. Class exceptions are mostly indistinguishable from strings, unless concatenated.

Base Classes (Categories)

Exception

Root superclass for all exceptions.

StandardError

Superclass for all other built-in exceptions; a subclass of the Exception root class.

ArithmeticError

Superclass for OverflowError, ZeroDivisionError, FloatingPointError; subclass of StandardError.

LookupError

Superclass for IndexError, KeyError; subclass of StandardError.

Specific Exceptions

AssertionError

Raised when an assert statement’s test is false.

AttributeError

On attribute reference or assignment failure.

EOFError

Immediate end-of-file hit by input( ) or raw_input( ).

FloatingPointError

When a floating-point operation fails.

IOError

I/O or file-related operation failure.

ImportError

On failure of import to find module or attribute.

IndexError

On out-of-range sequence offset (fetch or assign).

KeyError

On reference to non-existent mapping key (fetch).

KeyboardInterrupt

On user entry of the interrupt key (often Ctrl-C).

MemoryError

On recoverable memory exhaustion.

NameError

On failure to find a local or global unqualified name.

OverflowError

On excessively large arithmetic operation.

RuntimeError

Obsolete catch-all; define a suitable error instead.

SyntaxError

On parser encountering ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Python Pocket Reference, 5th Edition

Python Pocket Reference, 5th Edition

Mark Lutz

Publisher Resources

ISBN: 1565925009Catalog PageErrata