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


Groups > comp.lang.python > #77891

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

From Peter Otten <__peter__@web.de>
Subject __import__(name, fromlist=...), was Re: Shuffle
Date 2014-09-15 16:30 +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>
Newsgroups comp.lang.python
Message-ID <mailman.14029.1410791470.18130.python-list@python.org> (permalink)

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