Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I make Python 2.5 exit on ctrl-D in Windows instead of ctrl-Z?

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?

like image 400
Jason Baker Avatar asked Jun 10 '09 16:06

Jason Baker


People also ask

How do you exit Python in Anaconda prompt?

ctrl+c stops any process currently running. Use quit() to exit the console. Try typing in 'exit()' instead.


2 Answers

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.

like image 66
Kenan Banks Avatar answered Oct 02 '22 15:10

Kenan Banks


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)
like image 45
mechanical_meat Avatar answered Oct 02 '22 15:10

mechanical_meat