Movatterモバイル変換
[0]ホーム
[Python-Dev] BDFL-Delegate appointments for several PEPs
Nick Coghlanncoghlan at gmail.com
Sat Mar 30 11:26:49 EDT 2019
On Mon, 25 Mar 2019 at 20:34, Cameron Simpson <cs at cskk.id.au> 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 explicitlyunsupported, and nigh guaranteed to result in a broken import setup,as relative imports won't work, and absolute imports will most likelyresult in a second copy of the script module getting loaded.The problem is that __main__ always thinks it is a top-level modulefor directly executed scripts - it needs the package structureinformation from the "-m" switch to learn otherwise.Cheers,Nick.-- Nick Coghlan |ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-Devmailing list
[8]ページ先頭