diff -r ceb1ee4bc214 Doc/library/aifc.rst --- a/Doc/library/aifc.rst Tue Apr 23 09:58:04 2013 +0300 +++ b/Doc/library/aifc.rst Tue Apr 23 12:02:44 2013 +0300 @@ -96,7 +96,10 @@ .. method:: aifc.getparams() - Return a tuple consisting of all of the above values in the above order. + Return a :func:`~collections.namedtuple` consisting of all of the above values in the above order. + + .. versionchanged:: 3.4 + Return a :func:`~collections.namedtuple` instead of a tuple. .. method:: aifc.getmarkers() diff -r ceb1ee4bc214 Lib/aifc.py --- a/Lib/aifc.py Tue Apr 23 09:58:04 2013 +0300 +++ b/Lib/aifc.py Tue Apr 23 12:02:44 2013 +0300 @@ -69,7 +69,7 @@ getcomptype() -- returns compression type ('NONE' for AIFF files) getcompname() -- returns human-readable version of compression type ('not compressed' for AIFF files) - getparams() -- returns a tuple consisting of all of the + getparams() -- returns a namedtuple consisting of all of the above in the above order getmarkers() -- get the list of marks in the audio file or None if there are no marks @@ -252,6 +252,11 @@ _write_ulong(f, lomant) from chunk import Chunk +from collections import namedtuple + +_result = namedtuple('params', + 'nchannels sampwidth framerate nframes comptype compname') + class Aifc_read: # Variables used in this class: @@ -378,9 +383,9 @@ ## return self._version 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): if len(self._markers) == 0: @@ -658,8 +663,8 @@ 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): if id <= 0: diff -r ceb1ee4bc214 Lib/test/test_aifc.py --- a/Lib/test/test_aifc.py Tue Apr 23 09:58:04 2013 +0300 +++ b/Lib/test/test_aifc.py Tue Apr 23 12:02:44 2013 +0300 @@ -31,15 +31,16 @@ def test_params(self): f = self.f = aifc.open(self.sndfilepath) + params = f.getparams() self.assertEqual(f.getfp().name, self.sndfilepath) - self.assertEqual(f.getnchannels(), 2) - self.assertEqual(f.getsampwidth(), 2) - self.assertEqual(f.getframerate(), 48000) - self.assertEqual(f.getnframes(), 14400) - self.assertEqual(f.getcomptype(), b'NONE') - self.assertEqual(f.getcompname(), b'not compressed') + self.assertEqual(f.getnchannels(), params.nchannels) + self.assertEqual(f.getsampwidth(), params.sampwidth) + self.assertEqual(f.getframerate(), params.framerate) + self.assertEqual(f.getnframes(), params.nframes) + self.assertEqual(f.getcomptype(), params.comptype) + self.assertEqual(f.getcompname(), params.compname) self.assertEqual( - f.getparams(), + tuple(f.getparams()), (2, 2, 48000, 14400, b'NONE', b'not compressed'), ) @@ -299,7 +300,7 @@ fout.aifc() p = (1, 2, 3, 4, b'NONE', b'name') fout.setparams(p) - self.assertEqual(fout.getparams(), p) + self.assertEqual(tuple(fout.getparams()), p) fout.initfp(None) def test_write_header_raises(self):