By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,573 Members | 903 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,573 IT Pros & Developers. It's quick & easy.

clear screen / locate cursor

P: n/a
I am just trying to learn python, to use for some fairly basic command
line utilities which will run in either Windows/DOS or Linux. I cannot
find a platform neutral way of manipulating the screen. I don't want
to do anything complex, but just:-

1. Clear the screen
2. Print a string at an arbitrary x,y position
3. Receive a single key stroke

It seems that under Linux the curses module will do all this and more
(though I haven't tried it), but despite Python documentation curses
does not seem to be available under DOS. I have solved the 'clear
screen' problem with the code below, but made no progress on the other

def cls():
if a=='posix': #linux
elif a=='nt': #windows
else: #unknown
print ('='*(78-len(a)))+a

Is this the best solution? Can anyone help with the others? I have
tried searching python documentation and this newsgroup, but found no
pointers. It can't be difficult (for the experts!) - other cross
platform languages such as Yabasic and Euphoria seem to have such a
facility, so what am I missing?

The email address above was genuine once but has long been abandoned
to spam. Pleae reply via newsgroup or to

peter dot mosley at spamguardnorth dot org after removing spamguard

Thanks in advance for any help.
Jul 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.