[Newbie] List from a generator function

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Sun Jul 23 04:15:29 EDT 2006


In <e9va4g$q9h$1 at hefestos.uned.es>, 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?

What is `length`?  Do you want unique elements from `possible_notes`? 
Then you could use `random.sample()`.

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list