[Idle-dev] Dealing with a few feature requests

Tal Einat taleinat at gmail.com
Fri May 25 22:44:06 CEST 2007

On 5/25/07, Douglas S. Blank <dblank at brynmawr.edu> wrote:
> Another problem that we wrestle with is handling the current Python
> path. Am I wrong or does one has to go through some work in order to be
> able to "import myfile" where myfile.py might be in an arbitrary place.

If it's in an arbitrary place, yes. But this is when you usually use

One idea: if you open a file in some directory, that directory might be
> appended to the sys.path.

The directory from which python (or in this case, IDLE) is run from is added
to sys.path. And if you use "Run Module" from IDLE, the file is executed in
the shell.

Do you need something more than this?

FYI: we had to hack our own IDLE start program because we needed to:
> 1) Kill other IDLE processes (and their children) because sometimes
> students close IDLE in a harsh manner that leaves the child process
> running, which prevents us from restarting the serial connection to the
> robot.

Well, you -could- run IDLE without a subprocess (-n). What this would
achieve is that killing IDLE would leave no zombie process. But this too
seems like an ugly solution. Sorry, I don't have a better idea for you.

2) Wrap the PyShell.PyShell.cancel_callback code so that we can send a
> command to stop the robot whenever a CONTROL+C is encountered.

Sounds like a good solution to me!

3) Have the option of running some Python code automatically when we
> start (from a file called "mystart.py", if it exists).

This is the standard Python way to do it: 2.2.4 The Interactive
Startup File<http://docs.python.org/tut/node4.html#SECTION004240000000000000000><http://docs.python.org/tut/node4.html#SECTION004240000000000000000>

In IDLE, run IDLE with the -s flag to have the startup file run in the shell
before anything else. Just set the PYTHONSTARTUP or IDLESTARTUP environment
variable to the file which should be run.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/idle-dev/attachments/20070525/46da1f43/attachment.htm 

More information about the IDLE-dev mailing list