Default save path for Python IDLE?

2020-02-11 03:05发布

Does anyone know where or how to set the default path/directory on saving python scripts prior to running?

On a Mac it wants to save them in the top level ~/Documents directory. I would like to specify a real location. Any ideas?

11条回答
狗以群分
2楼-- · 2020-02-11 03:59

If you locate the idlelib directory in your Python install, it will have a few files with the .def extension. config-main.def has instructions on where to put the custom config files. However, looking through these I did not find any configurable paths (your install may vary). Looks like you might need to crack open the editor code to alter it.

查看更多
【Aperson】
3楼-- · 2020-02-11 04:01

If you open a module, that sets the default working directory.

Start IDLE.

File -> Open to open your file. And set the current working directory.

查看更多
放我归山
4楼-- · 2020-02-11 04:02

In my case, the default directory is set to the directory from which I launched IDLE. For instance, if I launched IDLE from a directory called 'tmp' in my home directory, the default save path is set to ~/tmp. So start your IDLE like this:

~/tmp $ idle
[...]
查看更多
欢心
5楼-- · 2020-02-11 04:04

It seems like you can get idle into the directory you want if you run any module from that directory.

I had previously tried opening idlemain.py through the path browser. I was able to open and edit the file, but it seemed like I wasn't able to save my modifications.

I'm just glad to hear other people are having this problem. I just thought I was being stupid.

查看更多
等我变得足够好
6楼-- · 2020-02-11 04:06

I actually just discovered the easiest answer, if you use the shortcut link labeled "IDLE (Python GUI)". This is in Windows Vista, so I don't know if it'll work in other OS's.

1) Right-click "Properties".

2) Select "Shortcut" tab.

3) In "Start In", write file path (e.g. "C:\Users...").

Let me know if this works!

查看更多
登录 后发表回答