In the windows python console, how to make Tab = four spaces?

Hello I would like that when I am in the python console tabbing will give me four spaces. Any ideas?


Asked by: Wilson257 | Posted: 30-11-2021






Answer 1

  1. Download and install AutoHotkey
  2. Write this script:

    SetTitleMatchMode 2
    #IfWinActive python
    tab::
    Send, {SPACE}
    Send, {SPACE}
    Send, {SPACE}
    Send, {SPACE}
    

Save it as tab-to-space.ahk, and doubleclick on the file.

Note: you might have to captalize "Python" to match your window tite. Or you can have "yhton" and it will match Jython too.

Answered by: Chelsea121 | Posted: 01-01-2022



Similar questions

Keep Windows Console open after a Python Error

File associations on my machine (winxp home) are such that a python script is directly opened with the python interpreter. If I double click on a python script a console window runs and every thing is fine - as long as there is no syntax error in the script. In that case the console window opens up for a moment but it is closed immediately. Too fast to read the error message. Of course their would be the po...


windows - Hide console from Python script?

This question already has answers here:


Getting python to print in UTF8 on Windows XP with the console

I would like to configure my console on Windows XP to support UTF8 and to have python detect that and work with it. So far, my attempts: C:\Documents and Settings\Philippe>C:\Python25\python.exe Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> print u'é' é >>> import s...


Python 2.7: output utf-8 in Windows console

Let's say s = u"test\u0627\u0644\u0644\u0647 \u0623\u0643\u0628\u0631\u7206\u767A\u043E\u043B\u043E\u043B\u043E" If I try to print it directly, >>> print s Traceback (most recent call last): File "<stdin>", line 1, in <module> UnicodeEncodeError: 'cp932' codec can't encode character u'\u0627' in position 4: illegal multibyte sequence


How to get size of the windows console in python

i need some program that get the current window size of the console i tried below program def get_windows_term_width(): from ctypes import windll, create_string_buffer h = windll.kernel32.GetStdHandle(-12) csbi = create_string_buffer(22) res = windll.kernel32.GetConsoleScreenBufferInfo(h, csbi) if res: import struct (bufx, bufy, curx, cury, wattr, left, top,...


python - How do I change what the X button does on the Windows console window?

I have a regular console window (Windows 8.1) in Python and I want to change what the close/X button does. When the game ends, it needs to do some clean up and stuff like that, so how do I override what it does?


python - How to select the raster font for the Windows console?

I want to select the Raster Font from the console so I can have "Pixel like" characters in the console which are 8x8 pixels big. It's because I have programmed a console game engine and now I want it to look nicer. Here is my code for changing the font and the size: import ctypes LF_FACESIZE = 32 STD_OUTPUT_HANDLE = -11 class COORD(ctypes.Structure): _fields_ = [("X", ctypes.c...


windows - Python cannot run in console mode

I use Anaconda3 installed python on Windows10. When I run python --version in git-bash, it works. $ python --version Python 3.7.3 $ which python /d/Programs/Anaconda3/python But when I run python, it output nothing and pending there $ python A image may be more clear here.


windows - How to get title name of console using python?

Is there any change of getting console title name instead of renaming it? I know that I can use i.e. ctypes.windll.kernel32.SetConsoleTitleW to set new title of the console but I just want to get title name and do not set new title.


windows - Python - Direct Output From One Console To Another

I am creating a new console, like so: console = subprocess.Popen("cmd", creationflags=subprocess.CREATE_NEW_CONSOLE) I am also launching a Python script, like so: process = subprocess.Popen(["python", "test.py"] But, I want the console output of the python script to be routed to the console created by the previous call, rather than the curr...


Keep Windows Console open after a Python Error

File associations on my machine (winxp home) are such that a python script is directly opened with the python interpreter. If I double click on a python script a console window runs and every thing is fine - as long as there is no syntax error in the script. In that case the console window opens up for a moment but it is closed immediately. Too fast to read the error message. Of course their would be the po...


How to hide Windows console with python Tkinter?

I tried renaming my .py file to .pyw. But compiling with py2exe does not make a difference. I tried using root.withdraw() but all it does is freeze the application, prevent the initial canvas from popping up, and fail to remove the command prompt window anyways. Does anyone have a solution? My root is: root = Tk()


windows - Hide console from Python script?

This question already has answers here:


Getting python to print in UTF8 on Windows XP with the console

I would like to configure my console on Windows XP to support UTF8 and to have python detect that and work with it. So far, my attempts: C:\Documents and Settings\Philippe>C:\Python25\python.exe Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> print u'é' é >>> import s...


Python 2.7: output utf-8 in Windows console

Let's say s = u"test\u0627\u0644\u0644\u0647 \u0623\u0643\u0628\u0631\u7206\u767A\u043E\u043B\u043E\u043B\u043E" If I try to print it directly, >>> print s Traceback (most recent call last): File "<stdin>", line 1, in <module> UnicodeEncodeError: 'cp932' codec can't encode character u'\u0627' in position 4: illegal multibyte sequence


How to get size of the windows console in python

i need some program that get the current window size of the console i tried below program def get_windows_term_width(): from ctypes import windll, create_string_buffer h = windll.kernel32.GetStdHandle(-12) csbi = create_string_buffer(22) res = windll.kernel32.GetConsoleScreenBufferInfo(h, csbi) if res: import struct (bufx, bufy, curx, cury, wattr, left, top,...


Python output on windows console getting garbled

I have a shell script, windows batch script and a python script. Shell script and batch script are entry points for unix and windows based env respectively which in turn invokes python script that takes foreign strings( French, Japanese or Chinese) as input, feeds it into database and displays the same in shell/console terminal. The above works fine in unix env. But while displaying output in windows console the non-englis...


Change python stdin stream to Windows Console input

I want to run a python 3 script giving it a file via stdin or manually typing data. E.g. let's suppose I want to print the contents of an input with one line. The script, called app.py would look something like this: from sys import stdin print("Input says:"+stdin.readline()) Then, I could run it in both of the following ways: 1. Passi...


python - How do I change what the X button does on the Windows console window?

I have a regular console window (Windows 8.1) in Python and I want to change what the close/X button does. When the game ends, it needs to do some clean up and stuff like that, so how do I override what it does?


windows - Python console can't deal with Unicode?

(I'm using Python 3.4 for this, on Windows) So, I have this code I whipped out to better show my troubles: #!/usr/bin/env python # -*- coding: utf-8 -*- import os os.startfile('C:\\téxt.txt') On IDLE it works as it should (it just opens that file I specified), but on Console (double-click) it keeps saying Windows can't find the file. Of course, if I try to open "text.txt" instead ...


windows - Create an icon in memory with win32 in python

What's a good way to generate an icon in-memory in python? Right now I'm forced to use pygame to draw the icon, then I save it to disk as an .ico file, and then I load it from disk as an ICO resource... Something like this: if os.path.isfile(self.icon): icon_flags = win32con.LR_LOADFROMFILE | win32con.LR_DEFAULTSIZE hicon = win32gui.LoadImage(hinst, ...


windows xp - Process size in XP from Python

I have a python script that can approach the 2 GB process limit under Windows XP. On a machine with 2 GB physical memory, that can pretty much lock up the machine, even if the Python script is running at below normal priority. Is there a way in Python to find out my own process size? Thanks, Gerry


How to find out if there is data to be read from stdin on Windows in Python?

This code select.select([sys.stdin], [], [], 1.0) does exactly what I want on Linux, but not in Windows. I've used kbhit() in msvcrt before to see if data is available on stdin for reading, but in this case it always returns 0. Additionally msvcrt.getch() returns '\xff' whereas sys.stdin.read(1) returns ...


How can I read system information in Python on Windows?

Following from this OS-agnostic question, specifically this response, similar to data available from the likes of /proc/meminfo on Linux, how can I read system information from Windows using Python (including, but...


windows xp - Cygwin and Python 2.6

New to python (and programming). What exactly do I need from Cygwin? I'm running python 2.6 on winxp. Can I safely download the complete Cygwin? It just seems like a huge bundle of stuff. Well, I keep running into modules and functionality (i.e. piping output) which suggest downloading various cygwin components. Will cygwin change or modify any other os functionality or have any other side effects?


windows - Using DPAPI with Python?

Is there a way to use the DPAPI (Data Protection Application Programming Interface) on Windows XP with Python? I would prefer to use an existing module if there is one that can do it. Unfortunately I haven't been able to find a way with Google or Stack Overflow. EDIT: I've taken the example code pointed to by "dF" and tweaked it into a standalone library which can be simply used at a high ...


windows - How do I create a webpage with buttons that invoke various Python scripts on the system serving the webpage?

I'm a hobbyist (and fairly new) programmer who has written several useful (to me) scripts in python to handle various system automation tasks that involve copying, renaming, and downloading files amongst other sundry activities. I'd like to create a web page served from one of my systems that would merely present a few buttons which would allow me to initiate these scripts remotely. The problem is that I do...


How do I create a windows service with Python


Python script - SCP on windows

How is it possible to do secure copy using python (windows native install - ActivePython). Unfortunately pexpect module is for unix only and we don't want cygwin locally. I wrote a script that based on pscp.exe win tool - but always stops at first execution becuse of fingerprint host id. and haven't found option to switch this off. the remote hosts are running ssh-server on cygwin (win 2003 servers). Thanks


windows - Example of how to use msilib to create a .msi file from a python module

Can anyone give me an example of how to use python's msilib standard library module to create a msi file from a custom python module? For example, let's say I have a custom module called cool.py with the following code class Cool(object): def print_cool(self): print "cool" and I wa...






Still can't find your answer? Check out these communities...



PySlackers | Full Stack Python | NHS Python | Pythonist Cafe | Hacker Earth | Discord Python



top