[Python-ideas] proposal: "python -m foo" should bind sys.modules['foo']
Paul Sokolovsky
pmiscml at gmail.com
Wed Aug 5 17:23:20 CEST 2015
Hello,
On Wed, 5 Aug 2015 02:14:55 -0600
Eric Snow <ericsnowcurrently at gmail.com> wrote:
> On Aug 4, 2015 11:46 PM, "Cameron Simpson" <cs at zip.com.au> wrote:
> >
> > On 04Aug2015 23:01, Eric Snow <ericsnowcurrently at gmail.com> wrote:
> >> Be sure to read through PEP 495.
>
> Sorry, I meant 395.
I'm sorry for possibly hijacking this thread, but it touches very much
issue I had on my mind for a while: being able to run modules inside
package as normal scripts. As this thread already has few people
knowledgeable of peculiarities of package imports, perhaps they can
suggest something.
Scenario:
There's a directory ("pkg" (representing Python namespace package)),
and inside it, there's bar.py of not relevant content and foo.py with
"from . import bar". What I'd like to do is (while inside "pkg"
directory):
python3 foo.py
Current behavior:
SystemError: Parent module '' not loaded, cannot perform relative import
Expected behavior:
"from . import bar" in foo.py is successful.
>
> -eric
--
Best regards,
Paul mailto:pmiscml at gmail.com
More information about the Python-ideas
mailing list