Above is the screen shot of the Spder IDE, on the left hand side(LHS) is the py script and on the right hand side(RHS) is the corresponding Ipython shell. When I hit the F5, commands from scripts get executed in the RHS Ipython shell. If I directly type cls in the RHS Ipython shell it works. But trying to accomplish the same from the py script from LHS is not working. Is it possible to clear screen with commands in the py script? Thanks
Asked
Active
Viewed 14 times
0
-
`os.system('cls')` only works in a real terminal. The `cls` command must be an extension of the spyder shell. – Jean-François Fabre Sep 24 '18 at 16:03
-
Thanks Jean-François Fabre . Any way to achieve the cls functionality from script please? – Forever Learner Sep 24 '18 at 16:04
-
it will work with system, but only from a terminal. Maybe try with `%cls` – Jean-François Fabre Sep 24 '18 at 16:05
-
related: https://github.com/spyder-ide/spyder/issues/4530 – Jean-François Fabre Sep 24 '18 at 16:06
-
Thanks again Jean-François Fabre for sharing the thread. Tried the %cls, it is giving syntax error. Same for the variations !clear. May be as you say only with terminal it will work. Not from py script within spyder IDE. – Forever Learner Sep 24 '18 at 16:11
-
From the answer https://stackoverflow.com/questions/2084508/clear-terminal-in-python/23075152?utm_campaign=google_rich_qa&utm_medium=organic&utm_source=google_rich_qa , print(chr(27) + "[2J") did the trick. – Forever Learner Sep 24 '18 at 16:23
-
@Jean-François Fabre , yes that is the same link I shared :) Voted to close the question as duplicate, not deleted it and kept it here as it is related to the spyder3. – Forever Learner Sep 25 '18 at 06:24
-
1I know, I copied your link so you could close as duplicate. – Jean-François Fabre Sep 25 '18 at 06:43
-
Thank you Jean-François Fabre :) – Forever Learner Sep 25 '18 at 10:37