Opening random line from file with random.shuffle()

Peter Hansen peter at engcorp.com
Wed Feb 13 23:06:06 EST 2002


synthespian wrote:
> 
>  I need to get a random line from a file.  I read in thins NG about a 
> "poorly" documented random.shuffle(), but I can't get it to work:

I just checked the documentation.  It seems well enough documented
to me, even indicating that it does not return anything but shuffles
the sequence in place.  Right above it is the choice() method,
which clearly behaves as you wish.  I find the comment about 
poor documentation quite curious in this case.



More information about the Python-list mailing list