(*promises)
return retpromise
This creates a Promise which awaits the resolution of all promises
        passed as arguments. Anything which is not a *promise* is
        considered to be immediately resolved and the face value taken as the
        resolution value

        If any of the promises is rejected, the promise will also be rejected
        with the value of the rejected promise.
This creates a Promise which awaits the resolution of all promises
        passed as arguments. Anything which is not a *promise* is
        considered to be immediately resolved and the face value taken as the
        resolution value
This creates a Promise which awaits the resolution of all promises passed as arguments . Anything which is not a * promise * is considered to be immediately resolved and the face value taken as the resolution value
def all(*promises):
        '''This creates a Promise which awaits the resolution of all promises
        passed as arguments. Anything which is not a *promise* is
        considered to be immediately resolved and the face value taken as the
        resolution value

        If any of the promises is rejected, the promise will also be rejected
        with the value of the rejected promise.
        '''
        if not promises:
            return Promise.resolve([])

        count = [None] * len(promises)
        results = count[:]  # copy

        # Promise that does nothing to start with
        retpromise = Promise()

        def thener(result, i):
            results[i] = result
            count.pop()
            if not count:  # all have delivered
                retpromise._resolve(results)

        def catcher(error):
            retpromise._reject(error)

        for i, promise in enumerate(promises):
            if isinstance(promise, Promise):
                promise \
                    .then(lambda x, i=i: thener(x, i)) \
                    .catch(catcher)
            else:
                count.pop()
                results[i] = promise

        if not count:  # no promises in iterable, resolve immediately
            return Promise.resolve(results)

        return retpromise
def all ( * promises ) : if not promises : return Promise . resolve ( [ ] ) count = [ None ] * len ( promises ) results = count [ : ] # copy # Promise that does nothing to start with retpromise = Promise ( ) def thener ( result , i ) : results [ i ] = result count . pop ( ) if not count : # all have delivered retpromise . _resolve ( results ) def catcher ( error ) : retpromise . _reject ( error ) for i , promise in enumerate ( promises ) : if isinstance ( promise , Promise ) : promise . then ( lambda x , i = i : thener ( x , i ) ) . catch ( catcher ) else : count . pop ( ) results [ i ] = promise if not count : # no promises in iterable, resolve immediately return Promise . resolve ( results ) return retpromise