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


Groups > comp.lang.python > #77891

__import__(name, fromlist=...), was Re: Shuffle

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.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; 'argument': 0.05; 'tree': 0.05; 'attribute': 0.07; 'python3': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'mkdir': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'header:User-Agent:1': 0.23; 'question': 0.24; 'skip:_ 20': 0.27; 'header:X-Complaints-To:1': 0.27; 'point': 0.28; 'appear': 0.29; "doesn't": 0.30; '"",': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'file': 0.32; 'linux': 0.33; 'url:python': 0.33; '(most': 0.33; 'skip:_ 10': 0.34; 'url:org': 0.36; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'files': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'url:3': 0.61; 'more': 0.64; 'anything.': 0.68; '2014,': 0.84; 'directories,': 0.84; 'serious': 0.97
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject __import__(name, fromlist=...), was Re: Shuffle
Date Mon, 15 Sep 2014 16:30:50 +0200
Organization None
References <ruk91al1vliuf3uobq1e0el2hrp61p6uf5@4ax.com> <5414F047.9030809@gmail.com> <mailman.14027.1410788105.18130.python-list@python.org> <5416f15e$0$30000$c3e8da3$5496439d@news.astraweb.com>
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding 8Bit
X-Gmane-NNTP-Posting-Host p57bdb20d.dip0.t-ipconnect.de
User-Agent KNode/4.13.3
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.14029.1410791470.18130.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1410791470 news.xs4all.nl 2948 [2001:888:2000:d::a6]:58198
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:77891

Show key headers only | View raw


Steven D'Aprano wrote:

> A serious question -- what is the point of the fromlist argument to
> __import__? It doesn't appear to actually do anything.
> 
> 
> https://docs.python.org/3/library/functions.html#__import__

It may be for submodules:

$ mkdir -p aaa/bbb
$ tree
.
└── aaa
    └── bbb

2 directories, 0 files
$ python3
Python 3.4.0 (default, Apr 11 2014, 13:05:11) 
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> __import__("aaa").bbb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'bbb'
>>> __import__("aaa", fromlist=["bbb"]).bbb
<module 'aaa.bbb' (namespace)>

Back to comp.lang.python | Previous | NextPrevious 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