Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default working directory for Python IDLE?

Is there a configuration file where I can set its default working directory? It currently defaults to my home directory, but I want to set it to another directory when it starts. I know I can do "import os" followed by "os.chdir("")" but that's kind of troublesome. It'd be great if there is a conf file that I can edit and change that setting, but I am unable to find it.

In particular, I've looked into my OS (Ubuntu)'s desktop entry '/usr/share/applications/idle-python3.2.desktop', which doesn't contain a conf file, but points to '/usr/lib/python3.2/idlelib/PyShell.py', which points to config-*.def conf files under the same folder, with 'config-main.def' being the most likely candidate. However I am unable to find where the default path is specified or how it can be changed.

It seems that the path is hard-coded in PyShell.py, though I could be wrong with my limited knowledge on Python. I will keep looking, but would appreciate it if somebody knows the answer on top of his or her head. Thanks in advance.

like image 347
HaiXin Tie Avatar asked Mar 12 '13 17:03

HaiXin Tie


2 Answers

All I had to do here (Linux Mint 18.2 Xfce) ...

Just add path in line "working directory" = "Arbeitsverzeichnis"

like image 111
kalle123 Avatar answered Sep 21 '22 18:09

kalle123


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...").

This is also my answer here: Default save path for Python IDLE? Let me know if this works!

like image 22
Steven Choi Avatar answered Sep 21 '22 18:09

Steven Choi