-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathModule 5.py
More file actions
32 lines (25 loc) · 752 Bytes
/
Module 5.py
File metadata and controls
32 lines (25 loc) · 752 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
'''
Module 5 - Comprehension , Files I\O , Exceptions
1) Comprehension - list,tuple,dictionary
2) files management - reading,Writing a file (with { contex manager } )
3) Exceptions - error handling
'''
# 1) Comprehension
# 2) Files I/O
# file = open('introduction','r') # reading by default
# print(file.mode)
# for i in file.readlines():
# print(i)
# file.close()
'''Contex manager
Closes the file automatically
it will also close files,if there are any exceptions that are thrown
'''
# with open('introduction','r') as reading:
# '''
# read() : reads all short files
# readline() : ` grabs each line
# readlines() : list []
# '''
# print(reading.re ad(1))sasa
# print("all done")