]> granicus.if.org Git - python/commitdiff
open(): Make the mode parameter optional; if omitted or None, use the
authorFred Drake <fdrake@acm.org>
Thu, 17 Jun 1999 15:18:47 +0000 (15:18 +0000)
committerFred Drake <fdrake@acm.org>
Thu, 17 Jun 1999 15:18:47 +0000 (15:18 +0000)
 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

index 1353b51b37669bde5a200237ce379e5a97928742..5344db2aeb9d5688c78b90ed15ed51d0edbe942b 100644 (file)
@@ -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'):