diff options
author | hut <hut@lavabit.com> | 2010-01-21 01:48:12 +0100 |
---|---|---|
committer | hut <hut@lavabit.com> | 2010-01-21 01:48:12 +0100 |
commit | b953eb51ab4f70f35e643a6b345a79b98d9cea98 (patch) | |
tree | 3973a9afdfc65b0389498c85ec9f4e67dbc8e936 /ranger | |
parent | e99d68577df610f885316c0d937d98bf8c0ede3c (diff) | |
download | ranger-b953eb51ab4f70f35e643a6b345a79b98d9cea98.tar.gz |
ext/flatten: flatten deques too.
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/ext/flatten.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/ranger/ext/flatten.py b/ranger/ext/flatten.py index 19342efe..55d3e82f 100644 --- a/ranger/ext/flatten.py +++ b/ranger/ext/flatten.py @@ -12,15 +12,17 @@ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +from collections import deque + def flatten(lst): """ Flatten an iterable. - All contained tuples, lists and sets are replaced by their + All contained tuples, lists, deques and sets are replaced by their elements and flattened as well. """ for elem in lst: - if isinstance(elem, (tuple, list, set)): + if isinstance(elem, (tuple, list, set, deque)): for subelem in flatten(elem): yield subelem else: |