davea at davea.name
Mon Sep 15 15:32:34 CEST 2014
Michael Torrie <torriem at gmail.com> Wrote in message:
> On 09/13/2014 05:47 PM, Seymore4Head wrote:
>> Here is a screenshot of me trying Dave Briccetti's quiz program from
>> the shell and it (the shuffle command) works.
>> Two questions
>> If you import random, do you need to "from random import shuffle"?
>> Why does shuffle work from the command line and not when I add it to
>> this program?
>> import random
>> import shuffle
>> print (nums)
>> I get:
>> No module named 'shuffle'
> You can do it two ways:
> Refer to it as random.shuffle()
> from random import shuffle
> I tend to use the first method (random.shuffle). That way it prevents
> my local namespace from getting polluted with random symbols imported
> from modules.
Or a third way:
shuffle = random.shuffle
More information about the Python-list