|
Original |
Translation |
|
1131
|
How do I keep editors from inserting tabs into my Python source?
|
|
|
1132
|
The FAQ does not recommend using tabs, and the Python style guide, :pep:`8`, recommends 4 spaces for distributed Python code; this is also the Emacs python-mode default.
|
|
|
1133
|
Under any editor, mixing tabs and spaces is a bad idea. MSVC is no different in this respect, and is easily configured to use spaces: Take :menuselection:`Tools --> Options --> Tabs`, and for file type "Default" set "Tab size" and "Indent size" to 4, and select the "Insert spaces" radio button.
|
|
|
1134
|
If you suspect mixed tabs and spaces are causing problems in leading whitespace, run Python with the :option:`-t` switch or run ``Tools/Scripts/tabnanny.py`` to check a directory tree in batch mode.
|
|
|
1135
|
How do I check for a keypress without blocking?
|
|
|
1136
|
|
1137
|
How do I emulate os.kill() in Windows?
|
|
|
1138
|
Prior to Python 2.7 and 3.2, to terminate a process, you can use :mod:`ctypes`::
|
|
|
1139
|
import ctypes def kill(pid): """kill function for Win32""" kernel32 = ctypes.windll.kernel32 handle = kernel32.OpenProcess(1, 0, pid) return (0 != kernel32.TerminateProcess(handle, 0))
|
|
|
1140
|
In 2.7 and 3.2, :func:`os.kill` is implemented similar to the above function, with the additional feature of being able to send CTRL+C and CTRL+BREAK to console subprocesses which are designed to handle those signals. See :func:`os.kill` for further details.
|
|