admin管理员组

文章数量:1356924

This is my simple python code that i used to simply paste using right-click or ctrl+v in windows 10.

In windows 11, the cmd or terminal wants to help me but is ruining my code and wasting my time. what is the reason behind this auto-indent? do developers really want us to work more for launching a multiline python code so we take python seriously?

number = 24
divisors = [2, 3, 4, 5, 6]

for d in divisors:
    if number % d == 0:
        print(f"{number} is a multiple of {d}")
    else:
        print(f"{number} is not a multiple of {d}")

but after pasting: (this auto-indent is not helping) it actually creates some errors and wastes my time. for example sometimes if my code has 1000 lines i have to stay awake for a night to type the code line by line.

This is my simple python code that i used to simply paste using right-click or ctrl+v in windows 10.

In windows 11, the cmd or terminal wants to help me but is ruining my code and wasting my time. what is the reason behind this auto-indent? do developers really want us to work more for launching a multiline python code so we take python seriously?

number = 24
divisors = [2, 3, 4, 5, 6]

for d in divisors:
    if number % d == 0:
        print(f"{number} is a multiple of {d}")
    else:
        print(f"{number} is not a multiple of {d}")

but after pasting: (this auto-indent is not helping) it actually creates some errors and wastes my time. for example sometimes if my code has 1000 lines i have to stay awake for a night to type the code line by line.

Share Improve this question edited Mar 27 at 23:23 Santiago Squarzon 61.6k5 gold badges24 silver badges54 bronze badges asked Mar 27 at 23:16 Amin KavianiAmin Kaviani 254 bronze badges 3
  • 1 "so we take Python seriously?" Maybe you just need a better terminal or a different OS? Windows 11 auto-indents by default. Try Shift + Ctrl + V to paste as plain text or use a real editor to not waste time. – Paolo Commented Mar 27 at 23:22
  • 2 Your issue seem to be most likely caused by Windows Terminal and unrelated to PowerShell itself. Your issue is also unrelated to programming in which case your question doesn't belong to this site. – Santiago Squarzon Commented Mar 27 at 23:23
  • 3 Why would you want to run 1000 lines of code interactively rather than editing and saving a script file and running that? – user19077881 Commented Mar 27 at 23:30
Add a comment  | 

1 Answer 1

Reset to default 0

Install an use iPython, and add it to Windows Terminal. FYI, here is my iPython profile (from %LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json)

            {
                "commandline": "ipython.exe",
                "font": 
                {
                    "face": "Courier New",
                    "size": 14
                },
                "guid": "{d816c293-704d-4ce2-aec9-33e46e1f900c}",
                "hidden": false,
                "icon": "C:\\Program Files\\Python313\\Lib\\test\\tkinterdata\\python.png",
                "name": "iPython",
                "startingDirectory": "D:\\BAT"
            }

Result:

本文标签: windows cmd autoindent for python codes problemStack Overflow