def _build_targets(self, targets):
        if not self._ids:
            # flush notification socket if no engines yet, just in case
            if not self.ids:
                raise error.NoEnginesRegistered("Can't build targets without any engines")
        
        if targets is None:
            targets = self._ids
        elif isinstance(targets, str):
            if targets.lower() == 'all':
                targets = self._ids
            else:
                raise TypeError("%r not valid str target, must be 'all'"%(targets))
        elif isinstance(targets, int):
            if targets < 0:
                targets = self.ids[targets]
            if targets not in self._ids:
                raise IndexError("No such engine: %i"%targets)
            targets = [targets]
        
        if isinstance(targets, slice):
            indices = list(range(len(self._ids)))[targets]
            ids = self.ids
            targets = [ ids[i] for i in indices ]
        
        if not isinstance(targets, (tuple, list, xrange)):
            raise TypeError("targets by int/slice/collection of ints only, not %s"%(type(targets)))
            
        return [util.asbytes(self._engines[t]) for t in targets], list(targets)
Turn valid target IDs or 'all' into two lists:
dataset/ETHPy150Open ipython/ipython-py3k/IPython/parallel/client/client.py/Client._build_targets