[issue22121] IDLE should start with HOME as the initial working directory

Steve Dower report at bugs.python.org
Mon Nov 19 18:40:21 EST 2018


Steve Dower <steve.dower at python.org> added the comment:

AFAICT, the best logic is this:

if os.path.normcase(os.getcwd()) == os.path.normcase(sys.prefix):
    os.chdir(get_default_location(sys.platform))

The only complexity is likely to be that "Documents" is localized on Windows, and SHGetFolderPathW [1] requires ctypes, though I wouldn't be surprised if there's a hidden English link available. There might be some trick necessary for macOS too. All the command line options will work for now, but will break in the future.

[1]: https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shgetfolderpathw

It's not real obvious, but when https://bugs.python.org/issue34977 lands - soon! - we'll get good PATH support back, including for Idle. This means you'll get "idle[3[.y]].exe" available globally that will do the same thing as the icon in Start. In this situation, the logic above is the _only_ option that will work properly, as there are no arguments we can pass. So forcing the CWD out of the install directory but otherwise leaving it alone is the best option.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue22121>
_______________________________________


More information about the Python-bugs-list mailing list