Re: [Newbie] List from a generator function

2006-07-24 Thread Paul Rubin
Sion Arrowsmith <[EMAIL PROTECTED]> writes: > Why the use of starmap() rather than > imap(random.choice, repeat(possible_notes)) > ? Hmm, not sure what I was thinking. I remember "imap... no that won't work... ok, starmap". It was late. It's late now. -- http://mail.python.org/mailman/listinfo

Re: [Newbie] List from a generator function

2006-07-24 Thread Sion Arrowsmith
Paul Rubin wrote: > print list(islice(starmap(random.choice, repeat((possible_notes,))), length)) Why the use of starmap() rather than imap(random.choice, repeat(possible_notes)) ? -- \S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/ ___ | "Frankly I have

Re: [Newbie] List from a generator function

2006-07-23 Thread Ernesto García García
Thank you guys. So the answer is to keep with the original form, perhaps with xrange. Ernesto -- http://mail.python.org/mailman/listinfo/python-list

Re: [Newbie] List from a generator function

2006-07-23 Thread Peter Otten
Ernesto García García wrote: > I'm sure there is a better way to do this: > > [random.choice(possible_notes) for x in range(length)] Note that "generator" has a fixed meaning in Python: http://www.python.org/dev/peps/pep-0255/ For generators you can use list(itertools.islice(gen()), length) W

Re: [Newbie] List from a generator function

2006-07-23 Thread Paul Rubin
Ernesto García García <[EMAIL PROTECTED]> writes: > >>[random.choice(possible_notes) for x in range(length)] > > > There is at least a better way to ask the question. The subject has > > nothing to do with the body of your post. Or am I missing something? > > Sorry, I should have explained bett

Re: [Newbie] List from a generator function

2006-07-23 Thread Ernesto García García
>>I'm sure there is a better way to do this: >> >>[random.choice(possible_notes) for x in range(length)] > There is at least a better way to ask the question. The subject has > nothing to do with the body of your post. Or am I missing something? Sorry, I should have explained better. I just wan

Re: [Newbie] List from a generator function

2006-07-23 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Ernesto García García wrote: > I'm sure there is a better way to do this: > > [random.choice(possible_notes) for x in range(length)] There is at least a better way to ask the question. The subject has nothing to do with the body of your post. Or am I missing something?

[Newbie] List from a generator function

2006-07-23 Thread Ernesto García García
Hi all, I'm sure there is a better way to do this: [random.choice(possible_notes) for x in range(length)] Regards, Ernesto -- http://mail.python.org/mailman/listinfo/python-list