Daniel Fetchinson a écrit :
Hi folks,

If I'm only interested in linux and windows I know I can do

################################
import os
import platform

if platform.system( ) == 'Linux':
    clear = 'clear'
else:
    clear = 'cls'

os.system( clear )
################################

or something equivalent using os.name and friends, but was wondering
why there is no platform independent way (i.e. the platform dependence
is taken care of by the python stdlib) of clearing a terminal. Sure,
there are many different terminals and many different operating
systems but in many areas python managed to hide all these
complexities behind a well defined API.

Why was clearing a terminal left out?


What you're talking about is a shell, not a terminal (a terminal is a physical device). And the shell is not necessarily part of the OS itself (there's no shortage of shells for unices / linux systems), so it doesn't belong to the os or platform modules.

FWIW, I can't tell for sure since I never used any other shell than bash, but I'm not sure your above code is garanteed to work on each and any possible unix shell.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to