Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
py3: no longer use file(name, kind)
Browse files Browse the repository at this point in the history
  • Loading branch information
Frédéric Chapoton committed Aug 14, 2016
1 parent 0a80508 commit 3f169d0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
10 changes: 4 additions & 6 deletions src/sage/game_theory/normal_form_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -1393,13 +1393,11 @@ def _solve_lrs(self, maximization=True):
game1_str, game2_str = self._Hrepresentation(m1, m2)

g1_name = tmp_filename()
with open(g1_name, 'w') as g1_file:
g1_file.write(game1_str)
g2_name = tmp_filename()
g1_file = file(g1_name, 'w')
g2_file = file(g2_name, 'w')
g1_file.write(game1_str)
g1_file.close()
g2_file.write(game2_str)
g2_file.close()
with open(g2_name, 'w') as g2_file:
g2_file.write(game2_str)

try:
process = Popen(['lrsnash', g1_name, g2_name],
Expand Down
8 changes: 4 additions & 4 deletions src/sage/game_theory/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ def format_lrs(self):
sage: game1_str, game2_str = g._Hrepresentation(A, -A)
sage: g1_name = tmp_filename()
sage: g2_name = tmp_filename()
sage: g1_file = file(g1_name, 'w')
sage: g2_file = file(g2_name, 'w')
sage: g1_file = open(g1_name, 'w')
sage: g2_file = open(g2_name, 'w')
sage: g1_file.write(game1_str)
sage: g1_file.close()
sage: g2_file.write(game2_str)
Expand Down Expand Up @@ -186,8 +186,8 @@ def format_lrs(self):
sage: game1_str, game2_str = g._Hrepresentation(A, B)
sage: g1_name = tmp_filename()
sage: g2_name = tmp_filename()
sage: g1_file = file(g1_name, 'w')
sage: g2_file = file(g2_name, 'w')
sage: g1_file = open(g1_name, 'w')
sage: g2_file = open(g2_name, 'w')
sage: g1_file.write(game1_str)
sage: g1_file.close()
sage: g2_file.write(game2_str)
Expand Down
20 changes: 8 additions & 12 deletions src/sage/plot/plot3d/base.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1517,22 +1517,18 @@ end_scene""" % (render_params.antialiasing,
scene = self._rich_repr_jmol(**kwds)
scene.jmol.save(filename)
elif ext == '.x3d':
outfile = file(filename, 'w')
outfile.write(self.x3d())
outfile.close()
with open(filename, 'w') as outfile:
outfile.write(self.x3d())
elif ext == '.stl':
outfile = file(filename, 'w')
outfile.write(self.stl_ascii_string())
outfile.close()
with open(filename, 'w') as outfile:
outfile.write(self.stl_ascii_string())
elif ext == '.amf':
# todo : zip the output file ?
outfile = file(filename, 'w')
outfile.write(self.amf_ascii_string())
outfile.close()
with open(filename, 'w') as outfile:
outfile.write(self.amf_ascii_string())
elif ext == '.ply':
outfile = file(filename, 'w')
outfile.write(self.ply_ascii_string())
outfile.close()
with open(filename, 'w') as outfile:
outfile.write(self.ply_ascii_string())
else:
raise ValueError('filetype {} not supported by save()'.format(ext))

Expand Down

0 comments on commit 3f169d0

Please sign in to comment.