From f9607821ade54ec75d8d91952b64ecf1bfde4923 Mon Sep 17 00:00:00 2001 From: Fred Drake Date: Thu, 17 Jun 1999 15:18:47 +0000 Subject: [PATCH] open(): Make the mode parameter optional; if omitted or None, use the mode attribute of the file object (if it has one), otherwise use 'rb'. The documentation should still show this as required until there's a new release. --- Lib/wave.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Lib/wave.py b/Lib/wave.py index 1353b51b376..5344db2aeb9 100644 --- a/Lib/wave.py +++ b/Lib/wave.py @@ -555,7 +555,12 @@ class Wave_write: self._file.seek(curpos, 0) self._datalength = self._datawritten -def open(f, mode): +def open(f, mode=None): + if mode is None: + if hasattr(f, 'mode'): + mode = f.mode + else: + mode = 'rb' if mode in ('r', 'rb'): return Wave_read(f) elif mode in ('w', 'wb'):