1AssertionError #Raised when assert statement fails.
2AttributeError #Raised when attribute assignment or reference fails.
3EOFError #Raised when the input() functions hits end-of-file condition.
4FloatingPointError #Raised when a floating point operation fails.
5GeneratorExit #Raise when a generator's close() method is called.
6ImportError #Raised when the imported module is not found.
7IndexError #Raised when index of a sequence is out of range.
8KeyError #Raised when a key is not found in a dictionary.
9KeyboardInterrupt #Raised when the user hits interrupt key (Ctrl+c or delete).
10MemoryError #Raised when an operation runs out of memory.
11NameError #Raised when a variable is not found in local or global scope.
12NotImplementedError #Raised by abstract methods.
13OSError #Raised when system operation causes system related error.
14OverflowError #Raised when result of an arithmetic operation is too large to be represented.
15ReferenceError #Raised when a weak reference proxy is used to access a garbage collected referent.
16RuntimeError #Raised when an error does not fall under any other category.
17StopIteration #Raised by next() function to indicate that there is no further item to be returned by iterator.
18SyntaxError #Raised by parser when syntax error is encountered.
19IndentationError #Raised when there is incorrect indentation.
20TabError #Raised when indentation consists of inconsistent tabs and spaces.
21SystemError #Raised when interpreter detects internal error.
22SystemExit #Raised by sys.exit() function.
23TypeError #Raised when a function or operation is applied to an object of incorrect type.
24UnboundLocalError #Raised when a reference is made to a local variable in a function or method, but no value has been bound to that variable.
25UnicodeError #Raised when a Unicode-related encoding or decoding error occurs.
26UnicodeEncodeError #Raised when a Unicode-related error occurs during encoding.
27UnicodeDecodeError #Raised when a Unicode-related error occurs during decoding.
28UnicodeTranslateError #Raised when a Unicode-related error occurs during translating.
29ValueError #Raised when a function gets argument of correct type but improper value.
30ZeroDivisionError #Raised when second operand of division or modulo operation is zero.
1EXAMPLE
2# Python program to demonstrate
3# AttributeError
4
5# Raises an AttributeError as there is no
6# method as fst for strings
7string = "WEBSITE { }".fst("SAM")
8print(string)
9
1# main.py
2import datetime
3
4from gw_utility.book import Book
5from gw_utility.logging import Logging
6
7
8def main():
9 try:
10 # Create list and populate with Books.
11 books = list()
12 books.append(Book("Shadow of a Dark Queen", "Raymond E. Feist", 497, datetime.date(1994, 1, 1)))
13 books.append(Book("Rise of a Merchant Prince", "Raymond E. Feist", 479, datetime.date(1995, 5, 1)))
14 books.append(Book("Rage of a Demon King", "Raymond E. Feist", 436, datetime.date(1997, 4, 1)))
15
16 # Output Books in list, with and without index.
17 Logging.line_separator('Books')
18 log_list(books)
19 Logging.line_separator('Books w/ index')
20 log_list(books, True)
21 # Output list element outside bounds.
22 Logging.line_separator('books[len(books)]')
23 Logging.log(f'books[{len(books)}]: {books[len(books)]}')
24 except IndexError as error:
25 # Output expected IndexErrors.
26 Logging.log_exception(error)
27 except Exception as exception:
28 # Output unexpected Exceptions.
29 Logging.log_exception(exception, False)
30
31
32def log_list(collection, include_index=False):
33 """Logs the each element in collection to the console.
34
35 :param collection: Collection to be iterated and output.
36 :param include_index: Determines if index is also output.
37 :return: None
38 """
39 try:
40 # Iterate by converting to enumeration.
41 for index, item in enumerate(collection):
42 if include_index:
43 Logging.log(f'collection[{index}]: {item}')
44 else:
45 Logging.log(item)
46 except IndexError as error:
47 # Output expected IndexErrors.
48 Logging.log_exception(error)
49 except Exception as exception:
50 # Output unexpected Exceptions.
51 Logging.log_exception(exception, False)
52
53
54if __name__ == "__main__":
55 main()
56
1AttributeError can be defined as an error that is raised when an attribute reference or assignment fails. For example, if we take a variable x we assined a value 10. In this process suppose we want to append another value to that variable. ... Because the variable is a integer type it's not support append method
1Just keep reading tutorial. It will be explained in Keep Results chapter.
2http://celery.readthedocs.org/en/latest/getting-started/first-steps-with-celery.html#keeping-results
3
4To start Celery you need to provide just broker parameter, which is required to send messages
5about tasks. If you want to retrieve information about state and results
6returned by finished tasks you need to set backend parameter.
7
8You can find full list with description in Configuration docs: CELERY_RESULT_BACKEND.
9http://celery.readthedocs.io/en/latest/userguide/configuration.html#std:setting-result_backend