How do i generate a tuple from a generator ?

E

eye zak

Hi,

I have a situation where i want a tuple from a generator/sequence
comprehension.
I am wondering, is this possible ? or is this just a bad idea all together?

class iterator(object):
__slots__ = ('__iters',)

def __init__(self,*args):
assert len(args) != 0
self.__iters = tuple( __builtins__.iter(arg) for arg in args )

def __iter__(self,*args):
return self

def next(self):
return [ i.next() for i in self.__iters ] # HERE I WANT A TUPLE

This can also be accomplished with a generator function, but requires
while True loop. is that better ?

Isaac
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top