diff --git a/seriously/SeriouslyCommands.py b/seriously/SeriouslyCommands.py index d56b394..3c40add 100755 --- a/seriously/SeriouslyCommands.py +++ b/seriously/SeriouslyCommands.py @@ -2,13 +2,12 @@ import operator, cmath import math as rmath -import random, itertools, sys, string, binascii, ast +import random, itertools, sys, string, ast from base64 import * from copy import deepcopy as _copy import collections from functools import reduce, lru_cache import struct -import types from itertools import zip_longest as izip from seriouslylib.cp437 import CP437 from seriouslylib.iterable import deque, as_list, zip_longest diff --git a/seriouslylib/iterable.py b/seriouslylib/iterable.py index 33243a1..492f8bc 100644 --- a/seriouslylib/iterable.py +++ b/seriouslylib/iterable.py @@ -1,36 +1,39 @@ #!/usr/bin/env python3 from collections import deque as _deque -from collections import Iterable -from itertools import islice, zip_longest as izip +from collections.abc import Iterable +from itertools import zip_longest as izip + def as_list(val, wrap=True): - #strings are iterables all the way down, so an exception needs to be made + # strings are iterables all the way down, so an exception needs to be made # else we get infinite recursion, which is bad # this only took me 2 hours to debug, new record! if not isinstance(val, Iterable) or isinstance(val, str): return [val] if wrap else val else: return [as_list(x, wrap=False) for x in val] - + + class deque(_deque): def copy(self): - if hasattr(_deque, 'copy'): + if hasattr(_deque, "copy"): return _deque.copy(self) else: return deque(x for x in self) - + def __getitem__(self, key): if isinstance(key, slice): return [x for x in self][key] else: return _deque.__getitem__(self, key) - + def reversed(self): tmp = self.copy() tmp.reverse() return tmp + def zip_longest(*iterables): for vals in izip(*iterables): - yield filter(lambda x:x is not None, vals) \ No newline at end of file + yield filter(lambda x: x is not None, vals)