Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #77856
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <torriem+gmail@torriefamily.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.030 |
| X-Spam-Evidence | '*H*': 0.94; '*S*': 0.00; 'imported': 0.09; 'namespace': 0.09; 'prevents': 0.09; 'works.': 0.09; 'random': 0.14; '"from': 0.16; 'command)': 0.16; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'modules.': 0.16; 'program?': 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; 'header:User-Agent:1': 0.23; 'tend': 0.24; 'header:In-Reply-To:1': 0.27; 'getting': 0.31; 'add': 0.35; 'method': 0.36; 'two': 0.37; 'message-id:@gmail.com': 0.38; '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-Virus-Scanned | amavisd-new at torriefamily.org |
| Date | Sat, 13 Sep 2014 19:32:55 -0600 |
| From | Michael Torrie <torriem@gmail.com> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131118 Thunderbird/17.0.11 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: Shuffle |
| References | <ruk91al1vliuf3uobq1e0el2hrp61p6uf5@4ax.com> |
| In-Reply-To | <ruk91al1vliuf3uobq1e0el2hrp61p6uf5@4ax.com> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | 7bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.14003.1410658396.18130.python-list@python.org> (permalink) |
| Lines | 32 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1410658396 news.xs4all.nl 2887 [2001:888:2000:d::a6]:48786 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:77856 |
Show key headers only | View raw
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.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Shuffle Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-09-13 19:47 -0400
Re: Shuffle Chris Angelico <rosuav@gmail.com> - 2014-09-14 10:28 +1000
Re: Shuffle Michael Torrie <torriem@gmail.com> - 2014-09-13 19:32 -0600
Re: Shuffle Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-09-13 22:10 -0400
Re: Shuffle Dave Angel <davea@davea.name> - 2014-09-15 09:32 -0400
Re: Shuffle Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-09-16 00:02 +1000
__import__(name, fromlist=...), was Re: Shuffle Peter Otten <__peter__@web.de> - 2014-09-15 16:30 +0200
csiph-web