Skip to content

Commit

Permalink
Tools/map_gen: Use with statement to open file.
Browse files Browse the repository at this point in the history
Lacking f.close after called open in the old code, though this is
not mandatory, use with statement is better.
  • Loading branch information
redfuture authored and yifeijiang committed Sep 10, 2018
1 parent d839276 commit 23b7265
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions modules/tools/map_gen/map_gen.py
Expand Up @@ -92,14 +92,14 @@ def create_lane(map, id):


fpath = sys.argv[1]
f = open(fpath, 'r')
points = []
for line in f:
line = line.replace("\n", '')
data = line.split(',')
x = float(data[0])
y = float(data[1])
points.append((x, y))
with open(fpath, 'r') as f:
for line in f:
line = line.replace("\n", '')
data = line.split(',')
x = float(data[0])
y = float(data[1])
points.append((x, y))

path = LineString(points)
length = int(path.length)
Expand Down

0 comments on commit 23b7265

Please sign in to comment.