implement 'util.advance()'

This commit is contained in:
Mike Fährmann
2017-12-03 01:38:24 +01:00
parent 0e5057b15d
commit 93482a1f88
3 changed files with 28 additions and 13 deletions

View File

@@ -20,6 +20,7 @@ import string
import _string
import hashlib
import datetime
import itertools
import urllib.parse
from . import text, exception
@@ -100,6 +101,13 @@ def parse_bytes(value, suffixes="bkmgtp"):
return 0
def advance(iterable, num):
""""Advance the iterable by 'num' steps"""
iterator = iter(iterable)
next(itertools.islice(iterator, num, num), None)
return iterator
def combine_dict(a, b):
"""Recursively combine the contents of b into a"""
for key, value in b.items():