views:

461

answers:

4

I'm used to ending the python interactive interpreter using Ctrl-d using Linux and OS X. On windows though, you have to use Ctrl-z and then enter. Is there any way to use Ctrl-d?

A: 

You can change the key set that Idle should be using.

  1. Under Options->"Configure IDLE..." go to the "Keys" tab.

  2. On the right you can select the "IDLE Classic Unix" key set.

NJChim
That if you're using IDLE (which you shouldn't anyway given its high suckage level)
nosklo
nosklo, Care to elaborate why IDLE sucks? Never felt that way.
Lakshman Prasad
second the question from becomingGuru: why IDLE sucks?
ΤΖΩΤΖΙΟΥ
+4  A: 

You can't use CTRL-D on windows.

CTRL-Z is a windows-specific control char that prints EOF. On *nix, it is typically CTRL+D. That's the reason for the difference.

You can, however, train yourself to use exit(), which is cross-platform.

Triptych
+1: Python never "sees" CTRL-D or CTRL-Z. It only sees EOF.
nosklo
Extra info http://en.wikipedia.org/wiki/End-of-file
nosklo
The python that's installed in Cygwin works with ctrl-d. However, if I change it over to my windows install of Python, ctrl-d doesn't work anymore.
Jason Baker
+3  A: 

Ctrl-d works to exit from IPython
(installed by python(x,y) package).

  • OS: WinXP
  • Python version: 2.5.4


Edit: I've been informed in the comments by the OP, Jason Baker, that Ctrl-d functionality on Windows OSes is made possible by the PyReadline package: "The pyreadline package is a python implementation of GNU readline functionality it is based on the ctypes based UNC readline package by Gary Bishop. It is not complete. It has been tested for use with windows 2000 and windows xp."


Since you're accustomed to *nix you may like that IPython also offers *nix-like shell functionality without using something like Cygwin...

  • Proper bash-like tab completion.
  • Use of / instead of \, everywhere
  • Persistent %bookmark's
  • %macro
  • %store. Especially when used with macros and aliases.
  • cd -. (easily jump around directory history). Directory history persists across sessions.
  • %env (see cookbook)
  • Shadow history - %hist and %rep (see cookbook)
  • %mglob
  • Expansion of $python_variables in system commands
  • var = !ls -la (capture command output to handy string lists)
Adam Bernier
Why not just simply use *nix ? ;)
Lakshman Prasad
@becomingGuru: Agreed. At home all I use is *nix.
Adam Bernier
I wish I had that option becomingGuru. :(
Jason Baker
Erm... I installed IPython and Ctrl-d doesn't seem to work to exit...
Jason Baker
Yeah, I figured that. I guess that means it's some kind of setting enabled by the python(x,y) software package!? If you're doing any Scipy or Numpy you might look into it.
Adam Bernier
It requires the pyreadlines library: http://ipython.scipy.org/moin/PyReadline/Intro If you update your answer to say that, I'll accept it.
Jason Baker
@Jason: Thanks for doing that research.
Adam Bernier
A: 

Run Cygwin Python if windowisms are bothering you... Unless what you are doing depends on pywin32 that is.

Peter Ericson
The problem with this is that AFAIK, I can run Windows python anywhere including Cygwin. I can run Cygwin Python only in Cygwin.
Jason Baker