Skip to content

Commit 13cab51

Browse files
authored
Merge pull request yidao620c#198 from cclauss/patch-3
file() was removed from Py3, use ‘with open()’ instead
2 parents 6b1d898 + 7cfd9a0 commit 13cab51

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

exts/smallseg.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ def __init__(self):
1616
curpath=_curpath
1717
self.d = {}
1818
print("loading dict...", file=sys.stderr)
19-
self.set([x.rstrip() for x in file(os.path.join(curpath,"main.dic")) ])
20-
self.specialwords= set([x.rstrip().decode('utf-8') for x in file(os.path.join(curpath,"suffix.dic"))])
19+
with open(os.path.join(curpath, "main.dic")) as in_file:
20+
self.set([x.rstrip() for x in in_file])
21+
with open(os.path.join(curpath,"suffix.dic")) as in_file:
22+
self.specialwords= set([x.rstrip().decode('utf-8') for x in in_file])
2123
print('dict ok.', file=sys.stderr)
2224
#set dictionary(a list)
2325
def set(self,keywords):

0 commit comments

Comments
 (0)