INFO1110 Lecture Notes - Lecture 3: Order Of Merit

9 views1 pages

Document Summary

Python supports context managers using the with keyword. By opening a le with the with keyword, python will know to close the le after you leave the with block. with open("sample. txt", "r") as f: print(f. readline()) print(f. readline()) # the file will be closed outside the with block. ---> 4 print(f. readline()) # the file will be closed outside the with block. An exception is an object that signals an unusual occurrence during execution. When the exception object is created, it is termed throwing an exception" (or in. Some common exceptions you can catch: typeerror, valueerror, filenotfounderror. A typeerror happens when you give a function the wrong type. value = int([2, 3]) # the int function expects a string.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents