Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #77887
| 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 | <python-python-list@m.gmane.org> |
| 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 <davea@davea.name> |
| Subject | Re: Shuffle |
| Date | Mon, 15 Sep 2014 09:32:34 -0400 (EDT) |
| Organization | news.gmane.org |
| References | <ruk91al1vliuf3uobq1e0el2hrp61p6uf5@4ax.com> <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 <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.14027.1410788105.18130.python-list@python.org> (permalink) |
| 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 |
Show key headers only | View raw
Michael Torrie <torriem@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. >> 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
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