Message292069
Thanks for taking a look at this. I think array is little used, so registering it as a member of some of the abstract base classes in collections could easily have been overlooked.
One of the prerequisites for membership in MutableSequence is a .clear() method, and array doesn't have one, though there is no reason why it shouldn't. Here's the workaround that I'm using:
import array
import collections
class array(array.array,
collections.MutableSequence):
__slots__ = ()
def __reversed__(self):
# this is a bit hacky
return reversed(self.tolist())
def clear(self):
self.__setitem__(slice(None), self.__class__(self.typecode))
Here are some results:
>>> a = array('f', [1,2,3,4])
>>> list(reversed(a))
[4.0, 3.0, 2.0, 1.0]
>>> a.clear()
>>> a
array('f') |
|
Date |
User |
Action |
Args |
2017-04-21 17:35:20 | Alexander Gosselin | set | recipients:
+ Alexander Gosselin, Jim Fasarakis-Hilliard |
2017-04-21 17:35:20 | Alexander Gosselin | set | messageid: <1492796120.43.0.97856581395.issue30130@psf.upfronthosting.co.za> |
2017-04-21 17:35:20 | Alexander Gosselin | link | issue30130 messages |
2017-04-21 17:35:20 | Alexander Gosselin | create | |
|