Re: [Python-Dev] BDFL-Delegate appointments for several PEPs

2019年3月30日 08:30:24 -0700

On 2019年3月25日 at 20:34, Cameron Simpson <[email protected]> wrote:
> Clearly the above needs to accomodate this, possibly with a fallback
> guess. Is sniffing the end components of __file__ at all sane? ending in
> idlelib/pyshell.py or pyshell.py? Or is that just getting baroque?
>
> I don't think these are strictly the same from some kind of purist
> viewpoint: the path might be anything - _is_ it reasonable to suppose
> that it has a module name (== importable/finding through the import
> path)?
Directly executing files from inside Python packages is explicitly
unsupported, and nigh guaranteed to result in a broken import setup,
as relative imports won't work, and absolute imports will most likely
result in a second copy of the script module getting loaded.
The problem is that __main__ always thinks it is a top-level module
for directly executed scripts - it needs the package structure
information from the "-m" switch to learn otherwise.
Cheers,
Nick.
-- 
Nick Coghlan | [email protected] | Brisbane, Australia
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to