Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #106694
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Python programs and relative imports |
| Date | 2016-04-09 03:11 +1000 |
| Message-ID | <mailman.94.1460135468.2253.python-list@python.org> (permalink) |
| References | <ndu70d$m0t$1@dont-email.me> <ne8o2e$van$1@dont-email.me> <CAPTjJmpNZkGE+eg_OnGYBw=0EDnGXq-KysE0qLiPNTp7NLATbA@mail.gmail.com> |
On Sat, Apr 9, 2016 at 2:59 AM, Rob Gaddi <rgaddi@highlandtechnology.invalid> wrote: > Rob Gaddi wrote: > >> Does anyone know the history of why relative imports are only available >> for packages and not for "programs"? It certainly complicates life. >> > > Really, no one? It seems like a fairly obvious thing to have included; > all of the reasons that you want to be explicit in saying: > > from . import mypkg > > in a package apply just as well in an executable script. But instead, > they've got different semantics such that you expressly _cannot_ use > relative imports in a script. This feels like such a glaring oversight > that there must have been some rationale behind it. You can use the simple "import mypkg" syntax to load these up. I'm not sure what you're looking for - do you want to prevent that syntax from working, to prevent accidental shadowing? ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Python programs and relative imports Rob Gaddi <rgaddi@highlandtechnology.invalid> - 2016-04-04 17:07 +0000
Re: Python programs and relative imports Rob Gaddi <rgaddi@highlandtechnology.invalid> - 2016-04-08 16:59 +0000
Re: Python programs and relative imports Chris Angelico <rosuav@gmail.com> - 2016-04-09 03:11 +1000
Re: Python programs and relative imports Rob Gaddi <rgaddi@highlandtechnology.invalid> - 2016-04-08 17:50 +0000
Re: Python programs and relative imports Chris Angelico <rosuav@gmail.com> - 2016-04-09 04:04 +1000
Re: Python programs and relative imports Ian Kelly <ian.g.kelly@gmail.com> - 2016-04-08 12:26 -0600
csiph-web