コード例 #1
0
ファイル: utils.py プロジェクト: 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
コード例 #2
0
ファイル: utils.py プロジェクト: 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
コード例 #3
0
ファイル: support.py プロジェクト: pombredanne/twoq
 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)