Ejemplo n.º 1
0
Archivo: utils.py Proyecto: lcrees/stuf
def exhaustcall(call, iterable, exception=StopIteration, _n=next):
    '''
    call function on an iterator until it's exhausted

    @param call: call that does the exhausting
    @param iterable: iterable to exhaust
    @param exception: exception marking end of iteration
    '''
    iterable = map(call, iterable)
    try:
        while True:
            _n(iterable)
    except exception:
        pass
Ejemplo n.º 2
0
Archivo: utils.py Proyecto: lcrees/stuf
def exhaustcall(call, iterable, exception=StopIteration, _n=next):
    '''
    call function on an iterator until it's exhausted

    @param call: call that does the exhausting
    @param iterable: iterable to exhaust
    @param exception: exception marking end of iteration
    '''
    iterable = map(call, iterable)
    try:
        while True:
            _n(iterable)
    except exception:
        pass
Ejemplo n.º 3
0
 def __repr__(self):
     if not self:
         return '%s()' % self.__class__.__name__
     items = ', '.join(map('%r: %r'.__mod__, self.most_common()))
     return '%s({%s})' % (self.__class__.__name__, items)