Re: [Python-ideas] Allow multiple imports from a package while preserving its namespace

2018-05-22 Thread Julian DeMille via Python-ideas
The fact of explicit dependency noting is why I suggested something that explicitly defines multiple imports in one line On Sat, Apr 28, 2018 at 9:28 PM Greg Ewing wrote: > Nick Coghlan wrote: > > I find the imports at the top of the file to be a nice > > catalog of

Re: [Python-ideas] Allow multiple imports from a package while preserving its namespace

2018-04-28 Thread Greg Ewing
Nick Coghlan wrote: I find the imports at the top of the file to be a nice catalog of external dependencies. Not only is it useful for human readers, it's also useful for packaging tools such as py2exe that need to know which modules are being used. I experimented once with auto-importing in

Re: [Python-ideas] Allow multiple imports from a package while preserving its namespace

2018-04-27 Thread Eric Snow
On Fri, Apr 27, 2018 at 5:14 AM, Nick Coghlan wrote: > Taking this idea in a completely different direction: what if we were > to take advantage of PEP 451 __spec__ attributes to enhance modules to > natively support implicit on-demand imports before they give up and > raise

Re: [Python-ideas] Allow multiple imports from a package while preserving its namespace

2018-04-27 Thread Eric Snow
On Thu, Apr 26, 2018 at 7:51 AM, Nick Coghlan wrote: > On 26 April 2018 at 23:37, Paul Moore wrote: >> What are the benefits of this over a simple "import "? > > Forcing submodule imports would be the main thing, as at the moment, > you have to choose

Re: [Python-ideas] Allow multiple imports from a package while preserving its namespace

2018-04-27 Thread Steve Barnes
On 27/04/2018 12:14, Nick Coghlan wrote: > On 27 April 2018 at 01:22, Serhiy Storchaka wrote: >> I think this special cases isn't special enough to introduce a special >> syntax. > > While I'm mostly inclined to agree, I do think it would be nice to > have a clean spelling

Re: [Python-ideas] Allow multiple imports from a package while preserving its namespace

2018-04-27 Thread Nick Coghlan
On 27 April 2018 at 01:22, Serhiy Storchaka wrote: > I think this special cases isn't special enough to introduce a special > syntax. While I'm mostly inclined to agree, I do think it would be nice to have a clean spelling for "ensure this module is fully imported, but don't

Re: [Python-ideas] Allow multiple imports from a package while preserving its namespace

2018-04-27 Thread Greg Ewing
Serhiy Storchaka wrote: 27.04.18 02:12, Greg Ewing пише: import display, event, mixer in pygame I read this as import display, event, mixer in pygame pygame.display = display pygame.event = event pygame.mixer = mixer del display, event, mixer in pygame It's meant

Re: [Python-ideas] Allow multiple imports from a package while preserving its namespace

2018-04-26 Thread Greg Ewing
Chris Angelico wrote: +0 for an easier way to import multiple submodules at once. It's not something I've personally had a need for, but it's a sane and logical thing to do. Maybe: import display, event, mixer in pygame or in pygame import display, event, mixer -- Greg

Re: [Python-ideas] Allow multiple imports from a package while preserving its namespace

2018-04-26 Thread Robert Vanden Eynde
I just ran into a similar problem, how to relatively import without binding the submodule. Let's say you have this : myapp/ urls.py views/ base.py When you're in urls.py and you want to relatively access Functions from base.py, you must use the from syntax. from .views import

Re: [Python-ideas] Allow multiple imports from a package while preserving its namespace

2018-04-26 Thread Chris Angelico
On Thu, Apr 26, 2018 at 11:53 PM, Julian DeMille via Python-ideas wrote: > That's the kind of thing I'm looking for. I've dealt with some library > authors who were highly against importing the root allowing me to access > submodules with hierarchy. With a package,

Re: [Python-ideas] Allow multiple imports from a package while preserving its namespace

2018-04-26 Thread Serhiy Storchaka
26.04.18 16:51, Nick Coghlan пише: Forcing submodule imports would be the main thing, as at the moment, you have to choose between repeating the base name multiple times (once per submodule) or losing the hierarchical namespace. If the base name is short, there are no problems with repeating

Re: [Python-ideas] Allow multiple imports from a package while preserving its namespace

2018-04-26 Thread Serhiy Storchaka
The following works today: Python 3.6.3 (default, Oct  4 2017, 06:09:15) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import os.path >>> os

Re: [Python-ideas] Allow multiple imports from a package while preserving its namespace

2018-04-26 Thread Julian DeMille via Python-ideas
That's the kind of thing I'm looking for. I've dealt with some library authors who were highly against importing the root allowing me to access submodules with hierarchy. On Thu, Apr 26, 2018 at 9:51 AM Nick Coghlan wrote: > On 26 April 2018 at 23:37, Paul Moore

Re: [Python-ideas] Allow multiple imports from a package while preserving its namespace

2018-04-26 Thread Nick Coghlan
On 26 April 2018 at 23:37, Paul Moore wrote: > On 26 April 2018 at 14:29, Julian DeMille via Python-ideas > wrote: >> I personally would like a feature where instead of doing `from ... import >> ...` (which imports the specified items into the

Re: [Python-ideas] Allow multiple imports from a package while preserving its namespace

2018-04-26 Thread Pradyun Gedam
On Thu, 26 Apr 2018 at 19:10 Julian DeMille via Python-ideas < python-ideas@python.org> wrote: > Some library authors get pretty pissy about implicit imports at the root > > On Thu, Apr 26, 2018, 09:37 Paul Moore wrote: > >> On 26 April 2018 at 14:29, Julian DeMille via

Re: [Python-ideas] Allow multiple imports from a package while preserving its namespace

2018-04-26 Thread Julian DeMille via Python-ideas
Some library authors get pretty pissy about implicit imports at the root On Thu, Apr 26, 2018, 09:37 Paul Moore wrote: > On 26 April 2018 at 14:29, Julian DeMille via Python-ideas > wrote: > > I personally would like a feature where instead of

Re: [Python-ideas] Allow multiple imports from a package while preserving its namespace

2018-04-26 Thread Paul Moore
On 26 April 2018 at 14:29, Julian DeMille via Python-ideas wrote: > I personally would like a feature where instead of doing `from ... import > ...` (which imports the specified items into the current namespace), one > could use something along the lines of `import .{ , ,

[Python-ideas] Allow multiple imports from a package while preserving its namespace

2018-04-26 Thread Julian DeMille via Python-ideas
I personally would like a feature where instead of doing `from ... import ...` (which imports the specified items into the current namespace), one could use something along the lines of `import .{ , , ... }` such that the imported modules/attributes could be accessed as `.`, etc. -- Thanks,