Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news2.arglkargh.de!news.mixmin.net!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'imported': 0.09; 'namespace': 0.09; 'prevents': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'way:': 0.09; 'works.': 0.09; 'wrote': 0.14; 'random': 0.14; '"from': 0.16; 'command)': 0.16; 'modules.': 0.16; 'program?': 0.16; 'received:80.91.229.3': 0.16; 'received:97': 0.16; 'received:plane.gmane.org': 0.16; 'symbols': 0.16; 'ways:': 0.16; 'wrote:': 0.18; 'module': 0.19; 'trying': 0.19; '(the': 0.22; 'command': 0.22; 'import': 0.22; 'shell': 0.22; 'print': 0.22; 'tend': 0.24; 'header:X-Complaints-To:1': 0.27; 'michael': 0.29; 'getting': 0.31; 'third': 0.33; 'add': 0.35; 'method': 0.36; 'two': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'dave': 0.60; 'first': 0.61; 'refer': 0.63; 'here': 0.66; 'url:v': 0.71; 'url:youtube': 0.71; 'url:i': 0.72; 'url:watch': 0.77; 'url:jpg': 0.83; 'quiz': 0.84; 'random,': 0.84; 'url:imgur': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dave Angel Subject: Re: Shuffle Date: Mon, 15 Sep 2014 09:32:34 -0400 (EDT) Organization: news.gmane.org References: <5414F047.9030809@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 97.73.240.7 X-Newsreader: PiaoHong.Usenet.Client.VIP:1.61 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 44 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1410788106 news.xs4all.nl 2864 [2001:888:2000:d::a6]:43486 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:77887 Michael Torrie 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. >> https://www.youtube.com/watch?v=VR-yNEpGk3g >> http://i.imgur.com/vlpVa5i.jpg >> >> 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 >> nums=list(range(1,11)) >> shuffle(nums) >> print (nums) >> >> I get: >> No module named 'shuffle' > > You can do it two ways: > Refer to it as random.shuffle() > > or > > 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: import random shuffle = random.shuffle -- DaveA