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


Groups > comp.lang.python > #77854

Re: Shuffle

References <ruk91al1vliuf3uobq1e0el2hrp61p6uf5@4ax.com>
Date 2014-09-14 10:28 +1000
Subject Re: Shuffle
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.14002.1410654536.18130.python-list@python.org> (permalink)

Show all headers | 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