clear screen returning 256 in python

Question:

I am using mac. I wrote the below code to clear the screen

>>> import os
>>> os.system('clear')

it should clear the screen but its returning 256

its returning 1 for

 import subprocess
>>> subprocess.call("clear")
Asked By: Code cracker

||

Answers:

I run os.system('clear') on Ubuntu 11.04 alternate : it cleared the screen.

The return value you get depends on the operating system as Python documentation states:

Note that POSIX does not specify the meaning of the return value of
the C system() function, so the return value of the Python function is
system-dependent.

Answered By: user3522371

I was having the same issue here. (and yes guys, ‘clear’ command on OSX terminal is like "cls" on windows.)

This solved my problem: use the terminal, not the Visual Studio Code Terminal, os IDLE (Python) Terminal. But the original Mac OSX terminal.

Answered By: Laikah
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.