summaryrefslogtreecommitdiffstats
path: root/Lib/sunau.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1993-12-17 15:25:27 (GMT)
committerGuido van Rossum <guido@python.org>1993-12-17 15:25:27 (GMT)
commit7bc817d5ba917528e8bd07ec461c635291e7b06a (patch)
treed244fa2c8a15248efe095823be9f5e690a2efe38 /Lib/sunau.py
parentaa14837bd00c28997dbde4014f8c994b9482def1 (diff)
downloadcpython-7bc817d5ba917528e8bd07ec461c635291e7b06a.zip
cpython-7bc817d5ba917528e8bd07ec461c635291e7b06a.tar.gz
cpython-7bc817d5ba917528e8bd07ec461c635291e7b06a.tar.bz2
* Mass change: get rid of all init() methods, in favor of __init__()
constructors. There is no backward compatibility. Not everything has been tested. * aiff.{py,doc}: deleted in favor of aifc.py (which contains its docs as comments)
Diffstat (limited to 'Lib/sunau.py')
-rw-r--r--Lib/sunau.py32
1 files changed, 14 insertions, 18 deletions
diff --git a/Lib/sunau.py b/Lib/sunau.py
index 2cb35a7..08e4d20 100644
--- a/Lib/sunau.py
+++ b/Lib/sunau.py
@@ -192,11 +192,12 @@ class Au_read:
break
else:
self._info = ''
- return self
- def init(self, filename):
- import builtin
- return self.initfp(builtin.open(filename, 'r'))
+ def __init__(self, f):
+ if type(f) == type(''):
+ import builtin
+ f = builtin.open(f, 'r')
+ self.initfp(f)
def __del__(self):
if self._file:
@@ -277,9 +278,11 @@ class Au_read:
self._file = None
class Au_write:
- def init(self, filename):
- import builtin
- return self.initfp(builtin.open(filename, 'w'))
+ def __init__(self, f):
+ if type(f) == type(''):
+ import builtin
+ f = builtin.open(f, 'w')
+ self.initfp(f)
def initfp(self, file):
self._file = file
@@ -293,7 +296,6 @@ class Au_write:
self._datalength = 0
self._info = ''
self._comptype = 'ULAW' # default is U-law
- return self
def __del__(self):
if self._file:
@@ -453,18 +455,12 @@ class Au_write:
self._datalength = self._datawritten
self._file.seek(0, 2)
-def open(filename, mode):
+def open(f, mode):
if mode == 'r':
- return Au_read().init(filename)
+ return Au_read(f)
elif mode == 'w':
- return Au_write().init(filename)
+ return Au_write(f)
else:
raise Error, "mode must be 'r' or 'w'"
-def openfp(filep, mode):
- if mode == 'r':
- return Au_read().initfp(filep)
- elif mode == 'w':
- return Au_write().initfp(filep)
- else:
- raise Error, "mode must be 'r' or 'w'"
+openfp = open