from operator import methodcaller
from six.moves import map
from pprint import pformat


def mapall(funcs, seq):
    """
    Parameters
    ----------
    funcs : iterable[function]
        Sequence of functions to map over `seq`.
    seq : iterable
        Sequence over which to map funcs.

    Yields
    ------
    elem : object
        Concatenated result of mapping each ``func`` over ``seq``.

    Example
    -------
    >>> list(mapall([lambda x: x + 1, lambda x: x - 1], [1, 2, 3]))
    [2, 3, 4, 0, 1, 2]
    """
    for func in funcs:
        for elem in seq:
            yield func(elem)


def same(*values):
    """
    Check if all values in a sequence are equal.

    Returns True on empty sequences.

    Example
    -------
    >>> same(1, 1, 1, 1)
    True
    >>> same(1, 2, 1)
    False
    >>> same()
    True
    """
    if not values:
        return True
    first, rest = values[0], values[1:]
    return all(value == first for value in rest)


def _format_unequal_keys(dicts):
    return pformat([sorted(d.keys()) for d in dicts])


def dzip_exact(*dicts):
    """
    Parameters
    ----------
    *dicts : iterable[dict]
        A sequence of dicts all sharing the same keys.

    Returns
    -------
    zipped : dict
        A dict whose keys are the union of all keys in *dicts, and whose values
        are tuples of length len(dicts) containing the result of looking up
        each key in each dict.

    Raises
    ------
    ValueError
        If dicts don't all have the same keys.

    Example
    -------
    >>> dzip_exact({'a': 1, 'b': 2}, {'a': 3, 'b': 4})
    {'a': (1, 3), 'b': (2, 4)}
    """
    if not same(*map(methodcaller('viewkeys'), dicts)):
        raise ValueError(
            "dict keys not all equal:\n\n%s" % _format_unequal_keys(dicts)
        )
    return {k: tuple(d[k] for d in dicts) for k in dicts[0]}

@@ -2,36 +2,30 @@
 rom 
-operator import methodcaller
+pprint import pformat%0A
 %0Afro
@@ -33,22 +33,16 @@
  six
-.moves
  import 
 map%0A
@@ -41,31 +41,39 @@
 ort 
-map%0Afrom pprint
+viewkeys%0Afrom six.moves
  import 
 pfor
@@ -68,23 +68,19 @@
  import 
-pfor
 ma
-t
+p
 %0A%0A%0Adef m
@@ -1648,30 +1648,16 @@
 map(
-methodcaller('
 viewkeys
 '), 
@@ -1656,10 +1656,8 @@
 keys
-')
 , di

Use six viewkeys.