Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #77854

Re: Shuffle

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!ecngs!feeder2.ecngs.de!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.040
X-Spam-Evidence '*H*': 0.92; '*S*': 0.00; 'variant': 0.09; 'cc:addr :python-list': 0.11; 'random': 0.14; '"from': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'program?': 0.16; 'wrote:': 0.18; 'command': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply- To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'sep': 0.31; 'url:python': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; '14,': 0.36; 'url:org': 0.36; 'two': 0.37; 'does': 0.39; 'url:3': 0.61; "'from'": 0.84; 'random,': 0.84; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=6UOeUSjc/0oMmyZykXONmG6bkEflvHuQRkqlEHmSUrM=; b=Q0dIGOUIV6Xoka3dX+XaredAVrpV4gR35CDDnjVu2f7hv/atyhZv5vXx0DxTCckjWd 5nDI7PDQEF8SCMQuEUNfaEoHVT+lTn6coNukcwuHupCSorsrUS8IyzUdY3HfEexWrU+c wPolwgxnNSw5DHaLQaMzX4NcFRyr3JUTiFEoz1225M9ZQg15Hf+GpypuklxfS/BzkAhF Er44nEmU1WzO6MXRRuChZsYP6DcQ3ZamxNeK67LkefzOw4IoEJCpwZb45f56exoArNu6 rhFGGJZFQIfdF+styXGUhY5gfK2wtrM8horIThQCRPKMYDDSe8xLHET5MBKskWag5Djw TGCg==
MIME-Version 1.0
X-Received by 10.50.176.202 with SMTP id ck10mr12770014igc.2.1410654533505; Sat, 13 Sep 2014 17:28:53 -0700 (PDT)
In-Reply-To <ruk91al1vliuf3uobq1e0el2hrp61p6uf5@4ax.com>
References <ruk91al1vliuf3uobq1e0el2hrp61p6uf5@4ax.com>
Date Sun, 14 Sep 2014 10:28:53 +1000
Subject Re: Shuffle
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
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.14002.1410654536.18130.python-list@python.org> (permalink)
Lines 18
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1410654536 news.xs4all.nl 2885 [2001:888:2000:d::a6]:45097
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:77854

Show key headers only | View raw


On Sun, Sep 14, 2014 at 9:47 AM, Seymore4Head
<Seymore4Head@hotmail.invalid> wrote:
> 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

To understand this, you need to understand what the 'from' import does:

https://docs.python.org/3/tutorial/modules.html#more-on-modules

It's not the same as "import shuffle", but is a variant of "import random".

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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