diff --git a/Lib/os.py b/Lib/os.py index 05e9c32c5a7117..07150e60bdd284 100644 --- a/Lib/os.py +++ b/Lib/os.py @@ -1118,3 +1118,10 @@ def add_dll_directory(path): cookie, nt._remove_dll_directory ) + +def clear(): + """ Runs the clear command in the shell """ + if name == 'nt': + system('cls') + else: + system('clear') diff --git a/Misc/NEWS.d/next/Library/2021-03-08-16-08-15.bpo-43432.Aq20oZ.rst b/Misc/NEWS.d/next/Library/2021-03-08-16-08-15.bpo-43432.Aq20oZ.rst new file mode 100644 index 00000000000000..863dad8f0ed5f0 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2021-03-08-16-08-15.bpo-43432.Aq20oZ.rst @@ -0,0 +1,3 @@ +Added function `clear` to module `os`. +This function clears the screen by running `cls` in windows and `clear` in unix. +Patch by parsa shahmaleki