Create a base class for exceptions defined by a module,exceptionsdefined,# create spe
Create a base class for exceptions defined by a module,exceptionsdefined,# create spe
# create specific exception classes for different error conditions:class Error(Exception): '''Base class for exceptions in this module.''' passclass InputError(Error): '''Exception raised for errors in the input. Attributes: expression -- input expression in which the error occurred message -- explanation of the error ''' def __init__(self, expression, message): self.expression = expression self.message = messageclass TransitionError(Error): '''Raised when an operation attempts a state transition that's not allowed. Attributes: previous -- state at beginning of transition next -- attempted new state message -- explanation of why the specific transition is not allowed ''' def __init__(self, previous, next, message): self.previous = previous self.next = next self.message = message
- Assign list to a list item,assignitem,L = ['Alread
- String literals span multiple lines in several ways.,l
- A Simple function definition: return a tuple.,definiti
- Generic access to DBM-style databases,dbm-styledatabas
- String formatting: Integer, Decimal and Hexadeciaml,,i
- range with step,rangestep,from math im
热门文章:
相关内容
- Assign list to a list item,assignitem,L = ['Alread
- String literals span multiple lines in several ways.,literalsmultip
- A Simple function definition: return a tuple.,definitiontuple,def q
- Generic access to DBM-style databases,dbm-styledatabases,import fil
- String formatting: Integer, Decimal and Hexadeciaml,,integerValue
- range with step,rangestep,from math im
- Zip function demo: returns a list of tuples,returnstuples,D1 = {}D
- Print lines/words/chars stats of files by extension,charsstats,'''P
- ord function demo,ordfunction,print ord('s
- tuples: swaps values,tuplesswapsvalues,nudge = 1win
评论关闭