| @@ -64,7 +64,7 @@ ZeroDivisionError: division by zero | |||||
| # Exemples d'erreurs | # Exemples d'erreurs | ||||
| * `b += 2` - **NameError** | * `b += 2` - **NameError** | ||||
| * `a / 9` - **ZeroDivisionError** | |||||
| * `a / 0` - **ZeroDivisionError** | |||||
| * `my_list[42]` - **IndexError** | * `my_list[42]` - **IndexError** | ||||
| * ``my_dict["bad-key"]`` - **KeyError** | * ``my_dict["bad-key"]`` - **KeyError** | ||||
| * `1 + "two"` - **TypeError** | * `1 + "two"` - **TypeError** | ||||
| @@ -169,7 +169,7 @@ if exists(): | |||||
| ```python | ```python | ||||
| try: | try: | ||||
| file = open(filename) | file = open(filename) | ||||
| catch IOError: | |||||
| except IOError: | |||||
| ... | ... | ||||
| finally: | finally: | ||||
| file.close() | file.close() | ||||
| @@ -181,7 +181,7 @@ Pas besoin de `finally` :) | |||||
| ```python | ```python | ||||
| try: | try: | ||||
| with file = open(filename): | |||||
| with open(filename) as file: | |||||
| lines = file.readlines() | lines = file.readlines() | ||||
| except FileNotFoundError: | except FileNotFoundError: | ||||
| print("Fichier non trouvé") | print("Fichier non trouvé") | ||||