Skip to content

Commit 951948c

Browse files
committed
fixed naming convention
Fixed naming convention for adhere to PIP-8
1 parent bd79783 commit 951948c

File tree

2 files changed

+25
-30
lines changed

2 files changed

+25
-30
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
import pickle
22

33

4-
def Bdelete():
4+
def bdelete():
55
# Opening a file & loading it
6-
F = open("studrec.dat", "rb")
7-
stud = pickle.load(F)
8-
F.close()
9-
10-
print(stud)
6+
with open("studrec.dat") as F:
7+
stud = pickle.load(F)
8+
print(stud)
119

1210
# Deleting the Roll no. entered by user
1311
rno = int(input("Enter the Roll no. to be deleted: "))
14-
F = open("studrec.dat", "wb")
15-
rec = []
16-
for i in stud:
17-
if i[0] == rno:
18-
continue
19-
rec.append(i)
20-
pickle.dump(rec, F)
21-
F.close()
12+
with open("studrec.dat") as F:
13+
rec = []
14+
for i in stud:
15+
if i[0] == rno:
16+
continue
17+
rec.append(i)
18+
pickle.dump(rec, F)
2219

2320

24-
Bdelete()
21+
bdelete()
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
import pickle
22

33

4-
def binaryread():
5-
B = open("studrec.dat", "rb")
6-
stud = pickle.load(B)
7-
print(stud)
4+
def binary_read():
5+
with open("studrec.dat") as b:
6+
stud = pickle.load(b)
7+
print(stud)
88

9-
# prints the whole record in nested list format
10-
print("contents of binary file")
9+
# prints the whole record in nested list format
10+
print("contents of binary file")
1111

12-
for ch in stud:
12+
for ch in stud:
1313

14-
print(ch) # prints one of the chosen rec in list
14+
print(ch) # prints one of the chosen rec in list
1515

16-
Rno = ch[0]
17-
Rname = ch[1] # due to unpacking the val not printed in list format
18-
Rmark = ch[2]
16+
rno = ch[0]
17+
rname = ch[1] # due to unpacking the val not printed in list format
18+
rmark = ch[2]
1919

20-
print(Rno, Rname, Rmark, end="\t")
20+
print(rno, rname, rmark, end="\t")
2121

22-
B.close
2322

24-
25-
binaryread()
23+
binary_read()

0 commit comments

Comments
 (0)