summaryrefslogtreecommitdiff
path: root/Lib/wave.py
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2013-04-10 12:31:43 -0400
committerR David Murray <rdmurray@bitdance.com>2013-04-10 12:31:43 -0400
commita044ed77f493393e831dfb91202e402599c2960c (patch)
treecdbb14d38f94e2611c1a321b2b0c18dc6bdf1fb6 /Lib/wave.py
parent555a61743c1d57c3daa8fee83e49c0552d571714 (diff)
downloadcpython-a044ed77f493393e831dfb91202e402599c2960c.tar.gz
#17487: wave.getparams now returns a namedtuple.
Patch by Claudiu Popa.
Diffstat (limited to 'Lib/wave.py')
-rw-r--r--Lib/wave.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/Lib/wave.py b/Lib/wave.py
index 54f030267a..e3bf2af53c 100644
--- a/Lib/wave.py
+++ b/Lib/wave.py
@@ -18,7 +18,7 @@ This returns an instance of a class with the following public methods:
getcomptype() -- returns compression type ('NONE' for linear samples)
getcompname() -- returns human-readable version of
compression type ('not compressed' linear samples)
- getparams() -- returns a tuple consisting of all of the
+ getparams() -- returns a namedtuple consisting of all of the
above in the above order
getmarkers() -- returns None (for compatibility with the
aifc module)
@@ -90,6 +90,10 @@ else:
big_endian = 0
from chunk import Chunk
+from collections import namedtuple
+
+_result = namedtuple('params',
+ 'nchannels sampwidth framerate nframes comptype compname')
class Wave_read:
"""Variables used in this class:
@@ -206,9 +210,9 @@ class Wave_read:
return self._compname
def getparams(self):
- return self.getnchannels(), self.getsampwidth(), \
- self.getframerate(), self.getnframes(), \
- self.getcomptype(), self.getcompname()
+ return _result(self.getnchannels(), self.getsampwidth(),
+ self.getframerate(), self.getnframes(),
+ self.getcomptype(), self.getcompname())
def getmarkers(self):
return None
@@ -398,8 +402,8 @@ class Wave_write:
def getparams(self):
if not self._nchannels or not self._sampwidth or not self._framerate:
raise Error('not all parameters set')
- return self._nchannels, self._sampwidth, self._framerate, \
- self._nframes, self._comptype, self._compname
+ return _result(self._nchannels, self._sampwidth, self._framerate,
+ self._nframes, self._comptype, self._compname)
def setmark(self, id, pos, name):
raise Error('setmark() not supported')