os.system('cls')

Python python at rgbaz.eu
Thu Dec 25 07:22:14 EST 2008


>
>
> 2008/12/25 Dennis van Oosterhout <de.slotenzwemmer at gmail.com>:
>> Hello Arno,
>>
>> thanks for the explanation! I have one more question: on the python
>> site it says it's better to replace the system commands by subprocess
>> and Popen.
>> Now I searched for some good example for my specific case (as I have
>> no idea how it should work and I don't get it any clearer by reading
>> http://docs.python.org/3.0/library/subprocess.html#module-subprocess)
>> and I found this:
>>
>>> import subprocess
>>> def clear():
>>>    subProcess.Popen('clear')
>>
>


On 25 dec 2008, at 13:11, Dennis van Oosterhout wrote:
> Btw...does that mean that system('cls') only works on Windows...or to
> say it otherwise: the program isn't platform independant?


what you are doing is executing a shell command.

look at it this way:

you open a DOS shell: start/run/command
there you enter the python interpreter by typing python (i think...)

now you can execute python commands

but if you want to execute DOS commands again,
you need to find a way to get "out" of python  and
back in to DOS

this is what happens...

so, "leaving" python brings you back into windows if you are on a  
windows system
thus you can't execute *nix commands and to answer your question,  
those commands
are system commands and so they are very system dependent ;)



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20081225/07125f55/attachment-0001.html>


More information about the Python-list mailing list