This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Add function `clear` to the `os` module
Type: enhancement Stage: patch review
Components: Library (Lib) Versions: Python 3.10
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: eryksun, parsampsh, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2021-03-08 12:05 by parsampsh, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 24784 open parsampsh, 2021-03-08 12:56
Messages (4)
msg388262 - (view) Author: parsa mpsh (parsampsh) * Date: 2021-03-08 12:05
I wanna add a new function named `clear` to the os module.
This function runs the `clear` command in the os.
but this function checks that is os windows, if yes, runs `cls`.
I'm working on my patch.
msg388266 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2021-03-08 13:39
The idea of adding some kind of clear_screen() function in the os or shutil module was discussed extensively on python-ideas a few months ago:

I would not want to clear the terminal scrollback buffer, in which case the implementation in Windows would need to use the console API and/or VT sequences instead of the CMD shell's CLS command.
msg388274 - (view) Author: parsa mpsh (parsampsh) * Date: 2021-03-08 18:01
Well, some times we are writing a flexible Text ui program. we may use `clear` lot of times. This should be used when we haven't any valuable data on the screen. Also, who that uses this function, knows this will clear valuable data :). Sometimes also i use this command. but every time a should check that is this operation windows or not, to determine `clear` or `cls`. I think this is very helpful for making this easier.
The best feature of Python is its simplicity and power. More helper functions to make the code shorter and knowable, is a good thing for Python. Also about the Windows API instead of `cls`, i don't know more thing. But i think its not a big problem and `cls` works.
msg388275 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-03-08 18:12
If you write a flexible Text ui program, you should use functions provided by a text ui library which you use to clear the screen or a part of screen.

If you want to call an external command, use os.system(), os.popen() or more flexible subprocess module. But I do not think it will help with Text UI.
Date User Action Args
2022-04-11 14:59:42adminsetgithub: 87598
2021-03-08 18:12:38serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg388275
2021-03-08 18:01:52parsampshsetmessages: + msg388274
2021-03-08 13:39:53eryksunsetnosy: + eryksun
messages: + msg388266
2021-03-08 12:56:02parsampshsetkeywords: + patch
stage: patch review
pull_requests: + pull_request23550
2021-03-08 12:05:40parsampshcreate