Brian Quinlan wrote:

> I would just write the function like this:
> 
> def genNumbers():
>     shuffle_nums = numbers[:]    # copy the list to preserve the orginal
>                                  # order (if it matters)
>     random.shuffle(shuffle_nums) # shuffle the entire list
>     return shuffle_nums[:5]      # return the first 5 elements

Thanks. Interesting idea. I did consider copying it, but does that hurt 
performance each time the function is called? I know it may not be 
noticeable, but I don't like the idea of doing unnecessary work like 
that, if it is in fact unnecessary.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to