screen clear question
Is there a command in Python to clear the screen? That is without writing multiple blank lines. Thanks. Jim C -- http://mail.python.org/mailman/listinfo/python-list
Newbie question - clearing screen @ interactive prompt
Hello, I use python on Mandrake 10.2 2005 Ltd edition. I am learning so i use python interactively. How do i clear the screen in python?? I simply type clear on the Linux prompt and the screen clears there. Is there a similar command in Python to clear the interactive screen?? Thanks in advance, Have a great day, Kaizer. -- http://mail.python.org/mailman/listinfo/python-list
Re: screen clear question
On Sun, 2005-01-02 at 11:31, jcollins wrote: Is there a command in Python to clear the screen? That is without writing multiple blank lines. Without knowing what 'screen' you're talking about, it's hard to say. If you mean clearing a terminal, you can call 'tput clear' or '/usr/bin/clear' on many UNIX systems; no idea about Windows. -- Craig Ringer -- http://mail.python.org/mailman/listinfo/python-list
[issue40765] clear screen in idle
New submission from sagar : please provide clear screen option in windows idle. clear screen means moving command line to start of the page. -- assignee: terry.reedy components: IDLE messages: 369870 nosy: sagarkancharlas, terry.reedy priority: normal severity: normal status: open title: clear screen in idle type: behavior versions: Python 3.10 ___ Python tracker <https://bugs.python.org/issue40765> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Font size
On Tue, 15 Feb 2005 21:22:43 GMT, Adam wrote: Please help me. How do you clear the screen and then display a number with an enlarged font size (about 300). Adam. To clear screen in windows : #at the beggining of the program import os #when you want to clear the screen os.system(cls) -- http://mail.python.org/mailman/listinfo/python-list
clear shell screen
Does anyone know how to clear the shell screen completely ? I tried import os and then os.system(clear) was said to have worked in Windows XP, but it's just bringing up another window, then it turns black and then it closes in within about a second moving the prompt at the os.system(clear) line . I've also tried os.system(cls) with the same results. thx -- http://mail.python.org/mailman/listinfo/python-list
Re: Clearing output screen
Ivan Shevanski wrote I know there is a way to do this, but google doesn't seem to want to find it =) There is a command to clear the output screen right? no, because output screen isn't a well-defined concept on modern operating systems. the following works in many cases: import os if os.name == nt: os.system(cls) else: os.system(clear) /F -- http://mail.python.org/mailman/listinfo/python-list
Clearing the screen
I'm doing some python programming for a linux terminal (just learning). When I want to completely redraw the screen, I've been using os.system(clear) This command works when using python in terminal mode, and in IDLE. However, when running a little .py file containing that command, the screen doesn't clear. What to do? -- http://mail.python.org/mailman/listinfo/python-list
Re: How to clear screen in Python interactive shell mode?
A. L. wrote: In Python interactive mode, is there some function acting like 'clear' command in bash? Could somebody here give some advice? Under Linux/UNIX system (on x86 at least) you can use the CTRL+L combination to clear the screen. I do not now similar for Windows and MACs. Les -- http://mail.python.org/mailman/listinfo/python-list
Re: Clearing the screen
you could always use ANSI escape codes: print \\033[2J for a screen clear, or print \\022[2j \033[0;0H to clear and reset the way os.system('clear') would work. check out http://www.termsys.demon.co.uk/vtansi.htm Seems like all that mud programming came in handy after all. Graham. -- http://mail.python.org/mailman/listinfo/python-list
clear the screen
How to clear the screen? For example, in the two player game. One player sets a number and the second player guesses the number. When the first player enters the number, it should be cleared so that the second number is not able to see it. My question is how to clear the number. Thank you! -- http://mail.python.org/mailman/listinfo/python-list
extension to idle to clear screen - but how to write to screen?
and here I thought I was going to finally be able to change the world AND contribute back to python with my amazing clear screen extension - but I can't get it to work. ;( Copying from ZoomHeight.py and someone else's clever print suggestion: - # My Clear extension: clear a window class Clear: menudefs = [ ('windows', [ ('_Clear', 'clear'), ]) ] def __init__(self, editwin): self.editwin = editwin def clear_event(self, event): for i in range(60): print -- It shows up as a menu item, but does not do anything. No output, nuffin. I did get some sort of 'no connection msg' playing around which leads me to believe that I can't really write to the window (at least not this simplistically)... Pointers? -- http://mail.python.org/mailman/listinfo/python-list
Re: Font size
Adam [EMAIL PROTECTED] wrote: How do you clear the screen and then display a number with an enlarged font size (about 300). what platform? what screen? 300 what? /F -- http://mail.python.org/mailman/listinfo/python-list
Clearing output screen
I know there is a way to do this, but google doesn't seem to want to find it =) There is a command to clear the output screen right? Thanks in advance, -Ivan -- http://mail.python.org/mailman/listinfo/python-list
Re: Font size
BOOGIEMAN [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Tue, 15 Feb 2005 21:22:43 GMT, Adam wrote: Please help me. How do you clear the screen and then display a number with an enlarged font size (about 300). Adam. To clear screen in windows : #at the beggining of the program import os #when you want to clear the screen os.system(cls) Thanks I'll try that. Adam. -- http://mail.python.org/mailman/listinfo/python-list
[issue40708] Clearing the screen of IDLE interactive mode in Windows
Sanmitha added the comment: Clearing the screen of IDLE interactive mode using the following code: import os os.system("cls") It doesn't clear the screen in Windows -- title: Malfunctioning of '\r' -> Clearing the screen of IDLE interactive mode in Windows ___ Python tracker <https://bugs.python.org/issue40708> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: screen clear question
import os # windows os.system(cls) # bash ( mac, linux ) os.system(clear) That's all I can account for. Daniel Bickett -- http://mail.python.org/mailman/listinfo/python-list
How to clear screen in Python interactive shell mode?
In Python interactive mode, is there some function acting like 'clear' command in bash? Could somebody here give some advice? Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list
Re: symbolic links, aliases, cls clear
If I may recommend an alternative, print \033[H\033[J the ansi sequence to clear the screen. -- http://mail.python.org/mailman/listinfo/python-list
Re: Clearing the screen
Arrgghh... Is there any way to edit posts on this thing? The os.system(clear) doesn't work at all in a module. -- http://mail.python.org/mailman/listinfo/python-list
Re: clear shell screen
Shawn Minisall [EMAIL PROTECTED] wrote: Does anyone know how to clear the shell screen completely ? I tried import os and then os.system(clear) was said to have worked in Windows XP, but it's just bringing up another window, then it turns black and then it closes in within about a second moving the prompt at the os.system(clear) line . I've also tried os.system(cls) with the same results. os.system('cls') works just fine from a command shell. I just tried it. Are you running from inside Pythonwin? If so, then what you are looking at is not a shell screen in any way. It's a simulation, and I don't know of any way to clear it. -- Tim Roberts, [EMAIL PROTECTED] Providenza Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Re: screen clear question
On Sun, 02 Jan 2005 14:23:07 +0800, Craig Ringer [EMAIL PROTECTED] wrote: On Sun, 2005-01-02 at 11:31, jcollins wrote: Is there a command in Python to clear the screen? That is without writing multiple blank lines. Without knowing what 'screen' you're talking about, it's hard to say. If you mean clearing a terminal, you can call 'tput clear' or '/usr/bin/clear' on many UNIX systems; no idea about Windows. On Windows the DOS CLS command will clear a command prompt, it also works for CP/M and VAX terminals too. Finally I think the curses module allows you to clear a window, including the main window - ie the terminal screen. In each case run CLS (or clear) via os.system() But the bottom line is that there is no builtin command because the mechanism is different on each platform. Alan G. Author of the Learn to Program website http://www.freenetpages.co.uk/hp/alan.gauld -- http://mail.python.org/mailman/listinfo/python-list
Re: Clearing output screen
On 11/6/05, Fredrik Lundh [EMAIL PROTECTED] wrote: Ivan Shevanski wrote I know there is a way to do this, but google doesn't seem to want to find it =) There is a command to clear the output screen right?no, because output screen isn't a well-defined concept on modern operating systems.the following works in many cases:import osif os.name == nt:os.system(cls)else:os.system(clear) /F--http://mail.python.org/mailman/listinfo/python-listThat seems to work just fine. Thanks Fredrik! -Ivan -- http://mail.python.org/mailman/listinfo/python-list
use CTRL+L for clearing the screen
Hi, I'm working on an interactive script. With raw_input user input is read and the script produces some output and offers the prompt again. I would like to add a clear screen feature, which would be activated with CTRL+L. How to do that? Another thing: raw_input waits until Enter but I'd like to clear the screen at the moment when CTRL+L is pressed. The script should be self-contained, thus I'd like to solve it by using the standard library only. Thanks, Laszlo -- http://mail.python.org/mailman/listinfo/python-list
[issue27771] Add a clear screen button or menu choice for IDLE
Terry J. Reedy added the comment: This is essentially a duplicate of your #17632, which proposed Clear Screen + Restart, which was closed as a duplicate of #6143, which has some patches. -- resolution: -> duplicate stage: needs patch -> resolved status: open -> closed superseder: -> IDLE - an extension to clear the shell window ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27771> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40711] Clearing the screen of IDLE interactive mode in Windows
New submission from Sanmitha : Clearing the screen of IDLE interactive mode using the following code: import os os.system("cls") It doesn't clear the screen in Windows. Actually these two statements have no effect at all. -- Added file: https://bugs.python.org/file49178/Error_clearing screen ___ Python tracker <https://bugs.python.org/issue40711> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: symbolic links, aliases, cls clear
mp [EMAIL PROTECTED] writes: i have a python program which attempts to call 'cls' but fails: sh: line 1: cls: command not found i tried creating an alias from cls to clear in .profile, .cshrc, and /etc/profile, but none of these options seem to work. my conclusion is that a python program that is executing does not use the shell (because it does not recognize shell aliases). is this correct? Yes. should i use a symbolic link? if so, where should i place it? You could, but I don't think it's the best solution. what is the difference between aliases and symbolic links? Aliases exist only in a shell. Symbolic links exist in the file system. if i execute a command like 'clear' to clear the screen, where does the shell look to find the command 'clear'? Generally it searches $PATH for an executable file called clear. I don't know Python very well (note the cross-post), but if it provides a way to detect which operating system you're running on, you could execute cls if you're on Windows, or clear if you're on a Unix-like system. Or there might be some Python library with a clear-screen function. Are you sure you want to clear the screen? If I run your program and it clears my screen for me, it could be erasing significant information. If you want complete control over the screen, you should probably use something like curses or ncurses (there may be a Python interface to it). -- Keith Thompson (The_Other_Keith) [EMAIL PROTECTED] http://www.ghoti.net/~kst San Diego Supercomputer Center * http://users.sdsc.edu/~kst We must do something. This is something. Therefore, we must do this. -- http://mail.python.org/mailman/listinfo/python-list
Re: extension to idle to clear screen - but how to write to screen?
On Nov 15, 10:20 pm, owl [EMAIL PROTECTED] wrote: and here I thought I was going to finally be able to change the world AND contribute back to python with my amazing clear screen extension - but I can't get it to work. ;( Copying from ZoomHeight.py and someone else's clever print suggestion: - # My Clear extension: clear a window class Clear: menudefs = [ ('windows', [ ('_Clear', 'clear'), ]) ] def __init__(self, editwin): self.editwin = editwin def clear_event(self, event): for i in range(60): print -- It shows up as a menu item, but does not do anything. No output, nuffin. I did get some sort of 'no connection msg' playing around which leads me to believe that I can't really write to the window (at least not this simplistically)... Pointers? Try this: self.editiwin.write('\n'*60) - Tal Einat reduce(lambda m,x:[m[i]+s[-1] for i,s in enumerate(sorted(m))], [[chr(154-ord(c)) for c in '.-,l.Z95193+179-']]*18)[3] P.S. Feel free to contact the idle-dev mailing list: idle-dev at python (dot) org -- http://mail.python.org/mailman/listinfo/python-list
Re: Clearing a DOS terminal in a script
Stephen_B wrote: On Dec 13, 11:21 am, Chris Mellon [EMAIL PROTECTED] wrote: It opens clear with it's own virtual terminal and clears that instead. Even when I launch the script from a cmd shell with python myscript.py? There's an ANSI control code you can use to reset the screen, try printing that. I googled Esc[2J as an ascii sequence that it is supposed to clear the screen. How do I send that? Stephen Normally you would do: import sys sys.stdout.write(chr(27)+'[2J') sys.stdout.flush() Unfortunately that doesn't clear the screen because the ANSI module isn't loaded by default. Use os.system('cls') as mentioned instead. -Larry -- http://mail.python.org/mailman/listinfo/python-list
Re: clear shell screen
En Mon, 29 Oct 2007 00:08:14 -0300, Shawn Minisall [EMAIL PROTECTED] escribi�: Does anyone know how to clear the shell screen completely ? I tried import os and then os.system(clear) was said to have worked in Windows XP, but it's just bringing up another window, then it turns black and then it closes in within about a second moving the prompt at the os.system(clear) line . I've also tried os.system(cls) with the same results. Try running cls from a command prompt. If it works, it should work from inside Python, using os.system(cls) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: symbolic links, aliases, cls clear
Floyd L. Davidson wrote: [EMAIL PROTECTED] wrote: If I may recommend an alternative, print \033[H\033[J Unfortunately, it is poor practice to hard code such sequences. Instead the proper sequence should be obtained from the appropriate database (TERMINFO or TERMCAP), and the easy way to do that is, tput clear Or clear(1), as also mentioned earlier. Yes, definitely don't want to hardcode the sequence. Definitely do use the appropriate terminal capabilities database (terminfo or termcap) in the appropriate manner (e.g. clear(1) or tput clear will handle that in the simple case of shell accessible means to clear the screen). Most UNIX(/LINUX/BSD/...) implementations support a large number of terminal types. E.g. on my system, I check and find that there are 1470 unique terminal types (descriptions) supported - and that's not including multiple aliases for the same terminal type/description (but it does count distinct names/files which have differing configurations, even if they are for the same terminal - such as changing certain options or behavior of a terminal, or using the terminal in distinct modes). Among those terminal types on my system, I find 154 distinct means of clearing the screen. Just for illustrative purposes, here are the top 10 I find, with count of how many distinct types (descriptions) use that particular sequence: 236 clear=\E[H\E[J, 120 clear=^L, 120 clear=\E[H\E[2J, 64 clear=\EH\EJ, 61 clear=\E[2J, 42 clear=\E[H\E[J$156, 38 clear=^Z, 36 clear=\E[H\E[J$50, 31 clear=\E[H\E[J$40, 29 clear=\E[2J\E[H, And of course, sending the wrong sequence (e.g. like trying some to see what works) can be highly problematic - it can do very nasty things to some terminals. E.g. I own one terminal, which among sequences it supports, is one which effectively says interpret the following hexadecimal character pairs as bytes, load them into RAM, and execute them - a relatively sure-fire way to crash the terminal if it is sent garbage (I used to run into that and other problems with some BBS systems that would presume everyone must be running something ANSI capable or that it was safe to do other tests such as see if certain sequences would render a blue square on one's screen). references: system call/function, in various programming languages clear(1) tput(1) terminfo(5) termcap(5) news:[EMAIL PROTECTED] news:[EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Font size
Please help me. How do you clear the screen and then display a number with an enlarged font size (about 300). Adam. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to clear screen in Python interactive shell mode?
Thank you very much. I have tested it under Cygwin, and that works. But it fails under Windows Python Shell Mode. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to clear screen in Python interactive shell mode?
I have tested it under windows python console, and it works. Thank you very much. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to clear screen in Python interactive shell mode?
elif os.name in (nt, dos, ce): # emacs/Windows What`s the right statement here? -- http://mail.python.org/mailman/listinfo/python-list
Re: screen clear question
Nick Coghlan wrote: Alan Gauld wrote: But the bottom line is that there is no builtin command because the mechanism is different on each platform. I'd have said it was because the inpreter is line-oriented rather than screen-oriented, but YMMV. Cheers, Nick. I would try doing a test against the resident OS the program is running against and set the clear command based on that. -- Thank you, Andrew Robert E-mail: [EMAIL PROTECTED] Ur: http://shardservant.no-ip.info -- http://mail.python.org/mailman/listinfo/python-list
Re: Clearing a DOS terminal in a script
On Dec 13, 11:21 am, Chris Mellon [EMAIL PROTECTED] wrote: It opens clear with it's own virtual terminal and clears that instead. Even when I launch the script from a cmd shell with python myscript.py? There's an ANSI control code you can use to reset the screen, try printing that. I googled Esc[2J as an ascii sequence that it is supposed to clear the screen. How do I send that? Stephen -- http://mail.python.org/mailman/listinfo/python-list
[issue43432] Add function `clear` to the `os` module
Serhiy Storchaka added the comment: If you write a flexible Text ui program, you should use functions provided by a text ui library which you use to clear the screen or a part of screen. If you want to call an external command, use os.system(), os.popen() or more flexible subprocess module. But I do not think it will help with Text UI. -- nosy: +serhiy.storchaka ___ Python tracker <https://bugs.python.org/issue43432> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: graphic memory animation
Peres wrote: Slow means more than 20ms to erase the screen. After double buffering it improved a lot , of course (16 ms) but I'll need a faster speed. are you measuring the time it takes to go from a populated screen to a blank screen? if so, you're probably seeing the screen refresh time (16 ms = 60 fps) rather than the time it takes to draw things. try disabling vertical sync in your display driver to see if that fixes the problem (if you do things the right way, you shouldn't have to do that: you should clear/copy and draw the new screen before you flip the buffers) /F -- http://mail.python.org/mailman/listinfo/python-list
IDLE: clearing the screen
Hello everyone, I am new to Python, and I have been using IDLE (v3.10.11) to run small Python code. However, I have seen that the output scrolls to the bottom in the output window. Is there a way to clear the output window (something like cls in command prompt or clear in terminal), so that output stays at the top? Thanks in anticipation! -- https://mail.python.org/mailman/listinfo/python-list
Re: Clearing the screen
Hi Iswor, If I understand you correctly then your program is writing output to a console/terminal window and you want to clear that window. I don't know of any library methods for that, but you might just do: os.system(cls) #for windows or os.system(clear) #for unix Not the most advanced solution though. --- Happy holidays! ~Lars -- http://mail.python.org/mailman/listinfo/python-list
Re: cursor positioning
Danny Milosavljevic wrote: Hi, Examples ESC[2JESC[H same as clear, clear screen, go home \rESC[Kprogress %dprobably what you want :) Well, like the good old Commodore times :) Thank you. Mage -- http://mail.python.org/mailman/listinfo/python-list
Re: Clearing the screen
mwt wrote: Arrgghh... Is there any way to edit posts on this thing? are you aware that you're posting to a usenet newsgroup? The os.system(clear) doesn't work at all in a module. works for me (as long as I'm running the code on a platform that has a clear command). in what way does it fail for you? /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems with sys.stout.flush()
Dennis Lee Bieber wrote: flush() is working perfectly fine -- it says transmit any data still held within internal buffers. It is NOT a clear screen, clear line terminal command. I was mistaken about the sys.stout.flush(). I understand it a little more now thanks -- http://mail.python.org/mailman/listinfo/python-list
[issue40765] clear screen in idle
Change by Terry J. Reedy : -- resolution: -> duplicate stage: -> resolved status: open -> closed superseder: -> IDLE - clear and restart the shell window type: behavior -> enhancement ___ Python tracker <https://bugs.python.org/issue40765> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
symbolic links, aliases, cls clear
i have a python program which attempts to call 'cls' but fails: sh: line 1: cls: command not found i tried creating an alias from cls to clear in .profile, .cshrc, and /etc/profile, but none of these options seem to work. my conclusion is that a python program that is executing does not use the shell (because it does not recognize shell aliases). is this correct? should i use a symbolic link? if so, where should i place it? what is the difference between aliases and symbolic links? if i execute a command like 'clear' to clear the screen, where does the shell look to find the command 'clear'? i'm using os x. thanks mp -- http://mail.python.org/mailman/listinfo/python-list
[issue6143] IDLE - an extension to clear the shell window
Terry J. Reedy added the comment: An SO question today got me to look more at SO questions and discussion, and this appears to be the most requested feature. https://stackoverflow.com/questions/1432480/any-way-to-clear-pythons-idle-window - 2009, 129 upvotes, 32 answers (not all read yet) ... (15 other hits for [python-idle] clear screen) https://stackoverflow.com/questions/54083355/how-to-clear-the-screen-in-idle-on-imac - 2019 today So I want to revisit this after we do a bit more on squeezer. I want to add 'Clear and Restart' to the Shell menu, as Raymond suggested, so I am inclined to 'clear and restart' this discussion by closing this issue and reopening #17632 as a followup. -- type: behavior -> enhancement versions: +Python 3.8 -Python 3.6 ___ Python tracker <https://bugs.python.org/issue6143> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: symbolic links, aliases, cls clear
[EMAIL PROTECTED] wrote: If I may recommend an alternative, print \033[H\033[J the ansi sequence to clear the screen. Or so you would hope (however, that is *not* what you have listed!). Unfortunately, it is poor practice to hard code such sequences. Instead the proper sequence should be obtained from the appropriate database (TERMINFO or TERMCAP), and the easy way to do that is, tput clear -- Floyd L. Davidsonhttp://www.apaflo.com/floyd_davidson Ukpeagvik (Barrow, Alaska) [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: goto, cls, wait commands
Mike Meyer wrote: Secondly, how do I clear screen (cls) from text and other content ? That depends on A: What type of display device you're using B: What type of interface is being rendered on that display (command line, GUI, IDE, etc) C: Perhaps what operating system you are using. D: Whether or not you have a display device at all. I run Python scripts from Cron whose sole output functionality is via email. I run Python scripts as daemons whose sole output functionality is syslog. are you the original poster? if so, can you explain why you asked how to clear the screen if you don't have a screen? /F -- http://mail.python.org/mailman/listinfo/python-list
Re: use CTRL+L for clearing the screen
Jabba Laci jabba.l...@gmail.com writes: I would like to add a clear screen feature, which would be activated with CTRL+L. How to do that? Another thing: raw_input waits until Enter but I'd like to clear the screen at the moment when CTRL+L is pressed. That sounds like a job for the standard library ‘readline’ module URL:http://docs.python.org/library/readline.html, an interface to the widely-used C library of the same name on free operating systems. -- \ “We demand rigidly defined areas of doubt and uncertainty!” | `\—Vroomfondel, _The Hitch-Hiker's Guide To The Galaxy_, Douglas | _o__)Adams | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: clear the screen
On Sat, 20 Apr 2013 19:45:46 -0700, Yuanyuan Li wrote: How to clear the screen? For example, in the two player game. One player sets a number and the second player guesses the number. When the first player enters the number, it should be cleared so that the second number is not able to see it. My question is how to clear the number. Thank you! What sort of screen? A GUI window, or in a terminal? If you have a GUI window, you will need to read the documentation for your GUI toolkit. If it is in a terminal, that will depend on the terminal. The best solution is to use Curses, if you can, but that is Unix only. Another solution is this: print(\x1b[H\x1b[2J) although that only works in some terminals, and it will not work in IDLE. Another solution is this: import os result = os.system(clear) # Linux, Mac, Unix or for Windows: result = os.system(cls) but again, it may not work in IDLE. Last but not least, if everything else fails, try printing a whole lot of blank lines: print(\n*100) ought to do it on all but the tallest terminals, and amazingly, it even works in IDLE! -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Fwd: IDLE: clearing the screen
On 05/06/2024 04:09, Cameron Simpson wrote: On 04Jun2024 22:43, Rob Cliffe wrote: import os def cls(): x=os.system("cls") Now whenever you type cls() it will clear the screen and show the prompt at the top of the screen. (The reason for the "x=" is: os.system returns a result, in this case 0. When you evaluate an expression in the IDE, the IDE prints the result. So without the "x=" you get an extra line at the top of the screen containing "0".) Not if it's in a function, because the IDLE prints the result if it isn't None, and your function returns None. So: def cls(): os.system("cls") should be just fine. Yes, you're right. Rob Cliffe -- https://mail.python.org/mailman/listinfo/python-list
Re: Fwd: IDLE: clearing the screen
On 04Jun2024 22:43, Rob Cliffe wrote: import os def cls(): x=os.system("cls") Now whenever you type cls() it will clear the screen and show the prompt at the top of the screen. (The reason for the "x=" is: os.system returns a result, in this case 0. When you evaluate an expression in the IDE, the IDE prints the result. So without the "x=" you get an extra line at the top of the screen containing "0".) Not if it's in a function, because the IDLE prints the result if it isn't None, and your function returns None. So: def cls(): os.system("cls") should be just fine. -- https://mail.python.org/mailman/listinfo/python-list
Re: How to clear screen in Python interactive shell mode?
On Thu, 15 Sep 2005 21:18:33 -0700, A. L. wrote: In Python interactive mode, is there some function acting like 'clear' command in bash? Could somebody here give some advice? Thanks in advance. Something like this may help: def clearscreen(numlines=100): Clear the console. numlines is an optional argument used only as a fall-back. import os if os.name == posix: # Unix/Linux/MacOS/BSD/etc os.system('clear') elif os.name in (nt, dos, ce): # DOS/Windows os.system('CLS') else: # Fallback for other operating systems. print '\n' * numlines -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
[issue39141] IDLE Clear function returns 256 on Mac OS Catalina
New submission from David Turner : Trying to set up shortcut function to clear screen but its not working as expected on my Mac OS Catalina -- below is txt from idle import os >>> cls= lambda: os.system('clear') >>> cls() 256 -- messages: 358908 nosy: twiste...@gmail.com priority: normal severity: normal status: open title: IDLE Clear function returns 256 on Mac OS Catalina type: behavior versions: Python 3.8 ___ Python tracker <https://bugs.python.org/issue39141> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Clearing the screen
On Sat, 11 Feb 2006 18:14:02 -0200, Felipe Almeida Lessa wrote: Em Sáb, 2006-02-11 às 12:04 -0800, mwt escreveu: I'm doing some python programming for a linux terminal (just learning). When I want to completely redraw the screen, I've been using os.system(clear) This command works when using python in terminal mode, and in IDLE. However, when running a little .py file containing that command, the screen doesn't clear. What to do? There's one escape sequence that does what you want. I am *not* sure if this solution is the correct one, but: $ clear | hd 1b 5b 48 1b 5b 32 4a |.[H.[2J| 0007 $ python Python 2.3.5 (#2, Nov 20 2005, 16:40:39) [GCC 4.0.3 2005 (prerelease) (Debian 4.0.2-4)] on linux2 Type help, copyright, credits or license for more information. print chr(0x1b)+chr(0x5b)+chr(0x48)+chr(0x1b)+chr(0x5b)+chr(0x32)+chr(0x4a), Or even easier: print \x1b[H\x1b[2J which may or may not work, depending on the terminal you are using. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why is there no platform independent way of clearing a terminal?
Daniel Fetchinson wrote: After getting the technicalities out of the way, maybe I should have asked: Is it only me or others would find a platform independent python API to clear the terminal useful? There are two kinds of programs: 1. Those that process input to output. If one of those suddenly started by clearing my screen, I'd just dump it. Also, if output is redirected to a file or piped into another program, that is basically useless or even hurting, since you then end up with control sequences in the file. 2. Those that provide a text-based interactive UI. Those typically not only clear the screen, but also control its whole layout and content, so there you don't only need ways to clear the screen but also to position the cursor or draw boxes etc. In that case you need a full curses library. Summary: No, I don't see the need for such an API. Cheers! Uli -- Sator Laser GmbH Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932 -- http://mail.python.org/mailman/listinfo/python-list
Re: Why is there no platform independent way of clearing a terminal?
After getting the technicalities out of the way, maybe I should have asked: Is it only me or others would find a platform independent python API to clear the terminal useful? There are two kinds of programs: 1. Those that process input to output. If one of those suddenly started by clearing my screen, I'd just dump it. Also, if output is redirected to a file or piped into another program, that is basically useless or even hurting, since you then end up with control sequences in the file. 2. Those that provide a text-based interactive UI. Those typically not only clear the screen, but also control its whole layout and content, so there you don't only need ways to clear the screen but also to position the cursor or draw boxes etc. In that case you need a full curses library. Summary: No, I don't see the need for such an API. Okay, that makes perfect sense, thanks for the exaplanation! I'll just live with the platform.system( ) check for this particular problem then. Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown -- http://mail.python.org/mailman/listinfo/python-list
Re: IDLE: clearing the screen
On 08/06/2024 20:18, Rob Cliffe via Python-list wrote: > OK, here is the advanced version: > import os > class _cls(object): > def __repr__(self): > os.system('cls') > return '' > cls = _cls() > > Now when you type > cls > it clears the screen. For me on a Mac it clears the terminal screen that I used to launch IDLE and prints a single blank line on the IDLE shell. (And I have to use "clear" instead of "cls" of course. A quick Google suggests that printing Ctrl-L (formfeed?) might be a platform agnostic solution. But that didn't work for me in IDLE either. I think this is one where the best bet is to go into the IDLE code and add a Shell submenu to clear screen! Apparently it's been on the workstack at idle-dev for a long time but is considered low priority... -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos -- https://mail.python.org/mailman/listinfo/python-list
Re: symbolic links, aliases, cls clear
On 2006-03-29, mp wrote: i have a python program which attempts to call 'cls' but fails: sh: line 1: cls: command not found i tried creating an alias from cls to clear in .profile, .cshrc, and /etc/profile, but none of these options seem to work. Why not call 'clear', since 'cls' does not exist? my conclusion is that a python program that is executing does not use the shell (because it does not recognize shell aliases). is this correct? Even shell scripts do not normally expand aliases. should i use a symbolic link? if so, where should i place it? what is the difference between aliases and symbolic links? What's the difference between a raven and a writing desk? if i execute a command like 'clear' to clear the screen, where does the shell look to find the command 'clear'? In a directory listed in the PATH variable. -- Chris F.A. Johnson, author |http://cfaj.freeshell.org Shell Scripting Recipes: | My code in this post, if any, A Problem-Solution Approach | is released under the 2005, Apress | GNU General Public Licence -- http://mail.python.org/mailman/listinfo/python-list
Re: symbolic links, aliases, cls clear
Keith Thompson [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] (Floyd L. Davidson) writes: [EMAIL PROTECTED] wrote: If I may recommend an alternative, print \033[H\033[J the ansi sequence to clear the screen. Or so you would hope (however, that is *not* what you have listed!). Unfortunately, it is poor practice to hard code such sequences. Instead the proper sequence should be obtained from the appropriate database (TERMINFO or TERMCAP), and the easy way to do that is, tput clear (Or clear.) But /clear/ merely uses tput clear. On the other hand, I think it's been at least a decade since I've used a terminal or emulator that's not VT100-compatible (i.e., accepts ANSI control sequences). Of course, I'll run into one the day after I start writing code that depends on that assumption. However, if you check out the various TERMINFO database entries for an assortment of VT100-compatible terminals, you *will* find variation! Plus, if a user has customized a terminal database, for who knows what reason... -- Floyd L. Davidsonhttp://www.apaflo.com/floyd_davidson Ukpeagvik (Barrow, Alaska) [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Clearing the screen
No guessing needed. If I just use os.system(clear) on its own, no problem. Also, if I use the magic formula you gave on its own, that works to. But in the app, (see below), neither command works. I'm missing something obvious, but I'm... missing it. def run(self, userinfo): Time when to do stuff self.teamname = userinfo[0] self.username = userinfo[1] self.refreshinterval = userinfo[2] self.statsfile = userinfo[3] print self.username, , self.teamname self.minutes = 0 while 1: try: Checks for internet stats once per hour if self.minutes == 0: self.get_online_stats(self.statsfile) self.minutes += 1 if self.minutes == 60: self.minutes = 0 self.output() time.sleep(60) #nite-nite except KeyboardInterrupt:#user types Ctrl-C print Bye bye. os.system(clear) sys.exit() def output(self): os.system(clear) #clear the screen print print * Monitor * print print * * self.get_unit_info('/opt/foldingathome/1/unitinfo.txt')#print the current unit info print \n last updated at, time.strftime(%Y-%m-%d %H:%M:%S, time.localtime(time.time())) print * * print *Stats** print * * self.get_saved_stats(self.statsfile) print * * print -- http://mail.python.org/mailman/listinfo/python-list
Re: clear shell screen
Hmm...it works fine within the command line but then when I import os in python and then try os.system(cls), i get that very fast opening/closing window and 0 inside the shell. Gabriel Genellina wrote: En Mon, 29 Oct 2007 00:08:14 -0300, Shawn Minisall [EMAIL PROTECTED] escribi�: Does anyone know how to clear the shell screen completely ? I tried import os and then os.system(clear) was said to have worked in Windows XP, but it's just bringing up another window, then it turns black and then it closes in within about a second moving the prompt at the os.system(clear) line . I've also tried os.system(cls) with the same results. Try running cls from a command prompt. If it works, it should work from inside Python, using os.system(cls) -- http://mail.python.org/mailman/listinfo/python-list
os.system('cls')
Hi there! I was searching for a way to clear the 'DOS screen'/command screen etc. and found that os.system('cls') works for this. I was just wondering where I can find al the commands which can be used for os.system(). I searched with google but I didn't find an answer. In the official python tutorial it says os.system('command') executes the command, but it doesn't say which commands exist (or I'm just blind). Does anyone have an answer for this question? Thanks, Devilly -- http://mail.python.org/mailman/listinfo/python-list
Re: how to do draw pattern with python?
On Sat, Sep 22, 2012 at 3:31 AM, Chris Angelico ros...@gmail.com wrote: It's an ANSI escape sequence, or rather two of them. The first one clears the screen, the second returns you to 0,0. (Isn't that implicit in the 2J code? Maybe I'm misremembering.) Ah. From Wikipedia: If n is two, clear entire screen (and moves cursor to upper left on MS-DOS ANSI.SYS). So adding \e[H is necessary. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: clear shell screen
En Mon, 29 Oct 2007 17:31:52 -0300, Shawn Minisall [EMAIL PROTECTED] escribió: Hmm...it works fine within the command line but then when I import os in python and then try os.system(cls), i get that very fast opening/closing window and 0 inside the shell. Try the other method menctioned in the Knowledge Base article: code How To Performing Clear Screen (CLS) in a Console Application From http://support.microsoft.com/kb/99261 Some non-Microsoft versions of C++ provide a clrscr function for clearing the screen in a DOS application. However, there is no Win32 Application Programming Interface (API) or C-Runtime function that will perform this function. To accomplish this task for a Win32 console application, use one of the following methods: - os.system(cls) - Write a function that will programmatically clear the screen The following function is my (GG) Python translation of the original C code as published in the Microsoft article, using Mark Hammond's pywin32 extensions: import win32api import win32console def cls(): Clear console screen TopLeft = win32console.PyCOORDType(0,0) csb = win32console.GetStdHandle(win32api.STD_OUTPUT_HANDLE) csbi = csb.GetConsoleScreenBufferInfo() size = csbi['Size'].X * csbi['Size'].Y; csb.FillConsoleOutputCharacter(u' ', size, TopLeft) csb.FillConsoleOutputAttribute(csbi['Attributes'], size, TopLeft); csb.SetConsoleCursorPosition(TopLeft) /code -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Clearing a DOS terminal in a script
On Dec 13, 2007 10:48 AM, Stephen_B [EMAIL PROTECTED] wrote: This doesn't seem to work in a dos terminal at the start of a script: from os import popen print popen('clear').read() Any idea why not? Thanks. It opens clear with it's own virtual terminal and clears that instead. There's an ANSI control code you can use to reset the screen, try printing that. -- http://mail.python.org/mailman/listinfo/python-list
[issue33893] Linux terminal shortcuts support in python shell
sebastin added the comment: I meant this on Python IDLE across all platforms. basic necessary enhancements for seamless use of IDLE should atleast have below feature supported. clear(used in MAC/LINUX TERMINAL) or cls(used in WINDOWS CMD PROMPT) - clear the PYTHON IDLE screen. up arrow - for the search history. If this enhancements is in progress/open state then its good, if rejected this be reconsidered ? -- ___ Python tracker <https://bugs.python.org/issue33893> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Exploring terminfo
In comp.lang.python, Barry Scott wrote: > Alan Gauld via Python-list wrote: >> I've written a short program that is supposed to >> - *clear the screen*, >> - read some input >> - display the result in a message *highlighted in bold*. >> - get input to end the program > It seems that curses does not allow you to mix raw stdin/stdout with its > calls. This sounds very plausable. In C, in curses one uses printw() not printf(). > If all you want is simple things like bold and clear I'd just use the > ANSI escape sequences directly. > > Are there any terminals that do not understand ANSI escape sequences > these days? Probably, I hear tales of people using odd set-ups from time to time. But that could just be the circles I hang out in. When I've wanted to do simple things like bold and clear, I've used the tput(1) tool. You can capture stdout from the tool and use the output over and over. Typically I've done this in shell scripts: #!/bin/sh bold=$(tput smso) # set mode stand out nobold=$(tput rmso) # remove mode stand out clear=$(tput clear) # clear screen home=$(tput home) # home, without clear for word in Ten Nine Eight Seven Six Five Four Three Two One; do echo "${clear}${bold}${word}${nobold} ..." sleep 1 done echo "${home}Nothing happens." exit Elijah -- adapting to python left as an excercise for the reader -- https://mail.python.org/mailman/listinfo/python-list
Re: extension to idle to clear screen - but how to write to screen?
On Nov 17, 3:27 pm, Tal Einat [EMAIL PROTECTED] wrote: On Nov 15, 10:20 pm, owl [EMAIL PROTECTED] wrote: and here I thought I was going to finally be able to change the world AND contribute back to python with my amazing clear screen extension - but I can't get it to work. ;( Copying from ZoomHeight.py and someone else's clever print suggestion: - # My Clear extension: clear a window class Clear: menudefs = [ ('windows', [ ('_Clear', 'clear'), ]) ] def __init__(self, editwin): self.editwin = editwin def clear_event(self, event): for i in range(60): print -- It shows up as a menu item, but does not do anything. No output, nuffin. I did get some sort of 'no connection msg' playing around which leads me to believe that I can't really write to the window (at least not this simplistically)... Pointers? Try this: self.editiwin.write('\n'*60) - Tal Einat reduce(lambda m,x:[m[i]+s[-1] for i,s in enumerate(sorted(m))], [[chr(154-ord(c)) for c in '.-,l.Z95193+179-']]*18)[3] P.S. Feel free to contact the idle-dev mailing list: idle-dev at python (dot) org Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: Why is there no platform independent way of clearing a terminal?
On 7/27/2010 12:58 PM, Daniel Fetchinson wrote: After getting the technicalities out of the way, maybe I should have asked: Is it only me or others would find a platform independent python API to clear the terminal useful? One problem is, Where would you put it? The OS module is for system calls, mostly based on posix. The system call involved in clearing a terminal is a write string call. *nix puts terminal control in a separate library. Another is, what next? clear_line? Pretty soon, we are back to curses. Still another problem is that most of us do not have terminals; we have screens and use them as such. OS-independent full-screen graphics/game libraries have clear screen commands. Similary, GUI systems have means of clearing text and canvas widgets, but should not be able to clear the whole screen. The turtle module has a clear command for its canvas, which would be the same regardless of underlying gui. So we already have several OS independent clear commands. On Windows, the DOS clr command only works withing a text-mode command window (once called a dos window). The same thing (os.system('clr') within an IDLE shell uselessly flashes a blank command window, which then disappears. Yeah, it is too bad windows did not use the obvious 'clear' like everyone? else. If command windows still imitate or can be set to imitate ansi terminals, then I would think curses is your best bet. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: screen clear question
On Mon, 03 Jan 2005 02:15:23 +1000, Nick Coghlan Alan Gauld wrote: But the bottom line is that there is no builtin command because the mechanism is different on each platform. I'd have said it was because the inpreter is line-oriented rather than screen-oriented, but YMMV. Yeah, that might be a reason as well :-) But then the early PC GW-Basic or BASICA interpreters were line based too but both provided a CLS command because the *programs* that were written were usually screen based... But they ran on a single OS so a CLS was easily possible. Alan G. Author of the Learn to Program website http://www.freenetpages.co.uk/hp/alan.gauld -- http://mail.python.org/mailman/listinfo/python-list
Re: Clearing the screen
It clears the screen by scrolling all the characters out of sight at the top of the terminal window. So the screen is blank, but not cleared in the sense that I mean it. The behavior I want is for the display to be effectively erased and ready to receive the next wave of data -- like you would do in a UI -- which is what I'm used to working with, which is why this is mildly frustrating, and at least 1/3 of why I sound like an idiot with this question. Anyway, I don't want it to scroll, just, in essense refresh. As a total Python noob, my approach has been os.system(clear) ,then print something. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and (n)curses
I've said it before and I'll say it again. Why does Python have no platform neutral commands for simple screen manipulation? yabasic (a 'hobby' type language - http://www.yabasic.de/) has commands clear screen, inkey$ and putscreen$ which perform the basic functions of clearing the screen, reading a key press and printing a string at an arbitrary xy position in either Windows or Linux, leaving all the messy implementation away from the user. For me, introducing similar commands in Python would be by far the biggest single improvement that could be made to the language. Yes, I know the argument that it's up to me to contribute such a module. But I'm afraid my knowledge and skill are way below the threshold needed for such work. Which is why I need it as an addition to the core language! Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Screen Control in WinXP and Linux
En Tue, 17 Apr 2007 19:06:38 -0300, peter [EMAIL PROTECTED] escribió: I've been wrestling on and off with this problem for over a year now, without success. Basically, I am looking for a simple set of screen and keyboard manipulation commands that will run identically under Linux and Windows. Nothing fancy - just clear the screen, print a string at an arbitrary xy position and detect a keystroke. I've googled around this newsgroup and elsewhere, and come across various suggestions (and even posted my own partial solutions), but still haven't come up with an elegant solution. What about curses (Linux) and Console (XP)? You could wrap just the bits needed for your application in a more-or-less generic way. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Clearing the screen
On Sat, 11 Feb 2006 22:26:08 -0800, mwt wrote: I can't seem to get that to behave properly. It works fine in a python shell, like you're demonstrating it, but not as a command in a module. Would you like to tell us how you are using it and what happens when you do, or would you like us to guess? Because it works for me, both as a stand-alone script: $ cat clear.py magic = \x1b[H\x1b[2J def clear(): print magic if __name__ == __main__: clear() $ python clear.py and also from inside Python as a module: import clear clear.clear() -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Standard Python 2.4 module like crypt for Windows?
Is there a module available in the standard library, for Python 2.4 running on Windows, like crypt for Python 2.4 running on *nix machines? I need to store database passwords in a Python 2.4 script, but obviously don't want them in clear text. I'm looking for a reasonable level of security. What are some of my options? Also wondering if, for PythonWin, there is a module that will display asterisks rather than echo entered passwords in clear text. I see I have access to the getpass module, but I can't get it to work--it still echos typed-in passwords to the screen as clear text. -- http://mail.python.org/mailman/listinfo/python-list
[issue42771] Implement interactive hotkey, Ctrl+L to clear the console in Windows.
New submission from Mike Miller : The Ctrl+L as clear-screen hotkey is supported just about everywhere, Unix and Windows, with the exceptions of cmd.exe and python.exe interactive mode. As the legacy cmd.exe can be easily replaced, that leaves python.exe. Likely needs to be configured via readline or its analog used under Windows. Documenting it would be good too. Am happy to help, write, or test. -- components: Windows messages: 383917 nosy: mixmastamyk, paul.moore, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: Implement interactive hotkey, Ctrl+L to clear the console in Windows. type: enhancement ___ Python tracker <https://bugs.python.org/issue42771> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Python strings outside the 128 range
Fredrik Lundh wrote: in the iso-8859-1 character set, the character é is represented by the code 0xE9 (233 in decimal). there's no mapping going on here; there's only one character in the string. how it appears on your screen depends on how you print it, and what encoding your terminal is using. Crystal clear. Thanks ! SB -- http://mail.python.org/mailman/listinfo/python-list
Re: Why is there no platform independent way of clearing a terminal?
On 2010-07-28, Jonathan Hartley tart...@tartley.com wrote: And Neil Cerutti, I think I'll just email the whole source tree to myself, and have a script that scans my inbox, unzips source trees and runs their tests. Much nicer. :-) Don't forget to clear the screen, though. That ties the whole program together. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
From: rusi rustompm...@gmail.com Its quite clear to everyone here that -- Octavian has no interest in a 21st century snazzy-looking toolkit Oh well I am interested, but with the condition that toolkit to be accessible, however Tkinter is not. Is it too much to expect from a 21st century snazzy-looking toolkit to be accessable to screen readers? Octavian -- http://mail.python.org/mailman/listinfo/python-list
Re: Clearing the screen
On 24 Dec 2004 15:33:26 -0800, Lars [EMAIL PROTECTED] wrote: Hi Iswor, If I understand you correctly then your program is writing output to a console/terminal window and you want to clear that window. I don't know of any library methods for that, but you might just do: well i am not doing any console i/o. Just simple one. i am trying to clear the IDLE (one of python IDE distributed with the original distribution) screen which is pretty easy but having to do import cls cls() everytime is boring (2 lines of boredom!!) so what i want is to be able to do just cls() and nothing more or even less!! ;-) os.system(cls) #for windows or os.system(clear) #for unix yeah i have used the 'os' module's system() method but that wasn't what i meant. Not the most advanced solution though. ;-) Thanx anyway mate. [snip] -- cheers, Ishwor Gurung -- http://mail.python.org/mailman/listinfo/python-list
Re: clear the screen
On 04/20/2013 10:45 PM, Yuanyuan Li wrote: How to clear the screen? For example, in the two player game. One player sets a number and the second player guesses the number. When the first player enters the number, it should be cleared so that the second number is not able to see it. My question is how to clear the number. Thank you! Welcome to the python mailing list. The first thing you'd have to specify is your environment. Are you writing a gui program, and if so, with which toolkit (tk, wx, etc.). Or are you writing a console program? The simplest portable way is to issue 50 or so newlines, so things scroll beyond easy visibility. Of course, many terminal programs can easily scroll back, perhaps by using the mouse wheel. If you want something better than that, you'd have to specify your Python version and Operating System. Then somebody familiar with the quirks of that particular system can chime in. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
[issue44760] Turtle Documentation - Contents Hyperlink conflict
New submission from Ray Kinane : In the Turtle module, there are 2 methods named "clear", one for turtle objects and one for screen objects. In the Turtle module documentation, in the contents section, in the "Turtle methods" section, under "More drawing control" the clear() method hyperlink does not point to the correct section in the article. It points to the section for the clear method for screen objects. There is another identical hyperlink issue in the same article due to 2 methods with the same name: "reset" -- assignee: docs@python components: Documentation messages: 398361 nosy: docs@python, ray_giraffe priority: normal severity: normal status: open title: Turtle Documentation - Contents Hyperlink conflict type: enhancement versions: Python 3.10, Python 3.11, Python 3.6, Python 3.7, Python 3.8, Python 3.9 ___ Python tracker <https://bugs.python.org/issue44760> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: cursor positioning
Hi, On Mon, 11 Jul 2005 15:29:41 +0200, Mage wrote: Dear All, I am writing a database import script in python and I would like to print the percentage of the process to the last line. I would like to update the last line at every percent. You know what I mean. How can the cursor be positioned to the last line or somewhere else on the screen? Curses starts with clearing the whole screen and it is overkill. Many modules are on the net but I would like to resolve this simply task with native python. I tried: for something: print chr(8)*20+mystring, but it is nasty and didn't work well. Mage If you only want to support ansi terminals (which is questionable, but possible), then there are escape codes that are very helpful (searching for ansi escape codes or something in google should help you find the remainder): the general syntax is ESC[parameteraction action usually is the first letter in the sequence, hence parameters are usually numbers (duh :)) ESC is chr(27) (ascii 27, octal \033) actions are Hcursor go home (top left corner usually) Cgo right parameter times Dgo left parameter times Ago up parameter times Bgo down parameter times Kclear to end of line 2J clear screen (yes, to every rule there are exceptions :), note that this does not make the cursor go home) mset color/highlight/formatting flags Examples ESC[2JESC[H same as clear, clear screen, go home \rESC[Kprogress %dprobably what you want :) The downside of this is that determining the size of the screen is pretty hard to do right. Process is usually, read TERM environment variable, read /etc/termcap (deprecated) co attribute (columns), li attribute (rows). That has been deprecated because of all those resizeable terminals out there. Now its something like outputting some magical stuff to make the terminal emulator send back the current sizes immediately once, and whenever they change. I'm not totally clear how that works since I'm too lazy to care :) What you want is probably prc = 0 for prc in range(100): sys.stderr.write(\r\033[KProgress %d%% ... % prc) sys.stderr.flush() time.sleep(0.5) though :) Note that this can wreck havoc onscreen if the terminal is smaller than what is needed to print that horizontally, so technically its not totally clean code. Hope that helps cheers, Danny -- http://mail.python.org/mailman/listinfo/python-list
[issue41820] ipaddress Library gives me incorrect results
Anudeep Balla added the comment: Greetings, Any Ip address containing 2 zeros or more are considered to be an invalid IP address. '172.16.254.00' *is not* equivalent to '172.16.254.0' I guess this small logic is causing the error I hope it makes it clear from the below images. Regards, Raj. [image: Screen Shot 2020-09-20 at 11.42.39 AM.png] [image: Screen Shot 2020-09-20 at 11.42.31 AM.png] [image: Screen Shot 2020-09-20 at 11.42.18 AM.png] [image: Screen Shot 2020-09-20 at 11.42.09 AM.png] On Sun, 20 Sep 2020 at 08:00, Eric V. Smith wrote: > > Eric V. Smith added the comment: > > Simplified: > >>> import ipaddress > >>> print(ipaddress.ip_address('172.16.254.00').version) > 4 > > So your concern is that you think '172.16.254.00' (or equivalently, > '172.16.254.0') shouldn't be treated as a valid IPv4 address. Is that > correct? > > Can you tell us why you think it's not a valid IPv4 address? I think > everything is working correctly here. > > -- > nosy: +eric.smith > > ___ > Python tracker > <https://bugs.python.org/issue41820> > _______ > -- Added file: https://bugs.python.org/file49465/Screen Shot 2020-09-20 at 11.42.31 AM.png Added file: https://bugs.python.org/file49466/Screen Shot 2020-09-20 at 11.42.39 AM.png Added file: https://bugs.python.org/file49467/Screen Shot 2020-09-20 at 11.42.18 AM.png Added file: https://bugs.python.org/file49468/Screen Shot 2020-09-20 at 11.42.09 AM.png ___ Python tracker <https://bugs.python.org/issue41820> __ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Why is there no platform independent way of clearing a terminal?
On Jul 28, 8:08 am, Ulrich Eckhardt eckha...@satorlaser.com wrote: Daniel Fetchinson wrote: After getting the technicalities out of the way, maybe I should have asked: Is it only me or others would find a platform independent python API to clear the terminal useful? There are two kinds of programs: 1. Those that process input to output. If one of those suddenly started by clearing my screen, I'd just dump it. Also, if output is redirected to a file or piped into another program, that is basically useless or even hurting, since you then end up with control sequences in the file. 2. Those that provide a text-based interactive UI. Those typically not only clear the screen, but also control its whole layout and content, so there you don't only need ways to clear the screen but also to position the cursor or draw boxes etc. In that case you need a full curses library. Summary: No, I don't see the need for such an API. Cheers! Uli -- Sator Laser GmbH Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932 Hey, Your point seems good and I don't mean to contradict, but out of interest, what do you think about an example like the following: I want to write a quick script which, notices whenever I save my source code, and re-runs the unit tests, displaying the output. I think I'd like it to clear the terminal before each re-run of the tests, so that it's immediately obvious what is output from the current run, as opposed to previous runs. Then I can keep my editor focussed, but leave that running in a terminal and trust it to simply display the current output from my tests. I did dash off a quick and dirty version of this once which did a system 'clear' or 'cls' depending on the platform, but to my dismay I found that on Windows this caused focus to jump briefly to the terminal every time it ran 'clear' (!), making it extremely annoying in use. So I wished there had been a simple cross-platform way to clear the terminal. (this, and printing colored text, was my initial use case for starting 'colorama') Is this a silly desire of mine, or simply an uncommon edge case that therefore isn't really significant? Best regards, Jonathan -- http://mail.python.org/mailman/listinfo/python-list
Re: recommend a graphics library for plotting by the pixel?
On 2011-10-04, Derek Simkowiak wrote: If this is strictly for 2D pixel graphics, I recommend using PyGame (aka SDL). Why do you not think it's the way to go? It was built for this type of thing. I only know PyGame because we did an exercise in recreating the old breakout game and messing around with it at a local Python group. I was under the mistaken impression from that exercise that you have to maintain a set of all the objects on the screen and redraw them all every time through the loop that ends with pygame.display.flip() --- *but* I now see that the loop starts with these: clock.tick(tick_rate) screen.fill((0,0,0)) # comes from screen = pygame.display.set_mode((screen_width,screen_height)) # before the loop and that I was then deleting hit bricks, calculating the new positions of the balls, and then redrawing everything that was left on the secondary screen because things were moving around and disappearing. I guess if I don't clear the screen at the beginning of the loop but just blit pixels onto it, when I call display.flip(), it will add the new blittings to what was already there? If that's true, this will be much easier than I thought. The only buttons I have in mind are pause, step, go, and quit, and I can just as easily do those with keypresses. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why is there no platform independent way of clearing a terminal?
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. Sorry, but that is completely wrong - the shell is irrelevant. clear is just a normal command line program that queries the termcap/terminfo database (possibly via the curses library) for the terminal specific sequence of characters that will clear the screen. It then writes those characters to stdout. The terminal, or (more usually these days) terminal emulator, then interprets those characters and takes the appropriate action. I'm not sure what the POSIX status of the clear command is, but I'd be surprised if it wasn't present on a UNIX/Linux system of any vintage. After getting the technicalities out of the way, maybe I should have asked: Is it only me or others would find a platform independent python API to clear the terminal useful? Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown -- http://mail.python.org/mailman/listinfo/python-list
Fwd: IDLE: clearing the screen
Welcome to Python! A great language for program development. Answers might be platform-dependent (are you using WIndows, Linux, etc.). However, the following works for me on WIndows. You can put it in the startup.py file so you don't have to type it every time you start up the IDLE. import os def cls(): x=os.system("cls") Now whenever you type cls() it will clear the screen and show the prompt at the top of the screen. (The reason for the "x=" is: os.system returns a result, in this case 0. When you evaluate an expression in the IDE, the IDE prints the result. So without the "x=" you get an extra line at the top of the screen containing "0".) I am sure that some jiggery-pokery could be used so you don't have to type the "()". But that's more advanced ... Best wishes Rob Cliffe On 04/06/2024 14:34, Cave Man via Python-list wrote: Hello everyone, I am new to Python, and I have been using IDLE (v3.10.11) to run small Python code. However, I have seen that the output scrolls to the bottom in the output window. Is there a way to clear the output window (something like cls in command prompt or clear in terminal), so that output stays at the top? Thanks in anticipation! -- https://mail.python.org/mailman/listinfo/python-list
Re: Clearing the screen
Em Sáb, 2006-02-11 às 12:04 -0800, mwt escreveu: I'm doing some python programming for a linux terminal (just learning). When I want to completely redraw the screen, I've been using os.system(clear) This command works when using python in terminal mode, and in IDLE. However, when running a little .py file containing that command, the screen doesn't clear. What to do? There's one escape sequence that does what you want. I am *not* sure if this solution is the correct one, but: $ clear | hd 1b 5b 48 1b 5b 32 4a |.[H.[2J| 0007 $ python Python 2.3.5 (#2, Nov 20 2005, 16:40:39) [GCC 4.0.3 2005 (prerelease) (Debian 4.0.2-4)] on linux2 Type help, copyright, credits or license for more information. print chr(0x1b)+chr(0x5b)+chr(0x48)+chr(0x1b)+chr(0x5b)+chr(0x32)+chr(0x4a), # Clears the screen! -- Quem excele em empregar a força militar subjulga os exércitos dos outros povos sem travar batalha, toma cidades fortificadas dos outros povos sem as atacar e destrói os estados dos outros povos sem lutas prolongadas. Deve lutar sob o Céu com o propósito primordial da 'preservação'. Desse modo suas armas não se embotarão, e os ganhos poderão ser preservados. Essa é a estratégia para planejar ofensivas. -- Sun Tzu, em A arte da guerra -- http://mail.python.org/mailman/listinfo/python-list
Re: Clearing a DOS terminal in a script
On Dec 14, 3:48 am, Stephen_B [EMAIL PROTECTED] wrote: This doesn't seem to work in a dos terminal at the start of a script: from os import popen print popen('clear').read() Any idea why not? Thanks. Maybe you are using a different dos terminal. What is clear? C:\junkclear 'clear' is not recognized as an internal or external command, operable program or batch file. C:\junkver Microsoft Windows XP [Version 5.1.2600] C:\junkhelp cls Clears the screen. CLS C:\junk The following works for me: code import os os.system('cls') print 'Howzat?' /code To use ANSI escape sequences with the real MS-DOS, one needed a console device driver (ANSI.SYS was supplied) and had to invoke it in the CONFIG.SYS file; presumably you can find out how to set this up in a Windows Command Prompt window, but it doesn't seem to be worth the bother if all you want to do is clear the window. HTH, John -- http://mail.python.org/mailman/listinfo/python-list
Re: symbolic links, aliases, cls clear
[EMAIL PROTECTED] (Floyd L. Davidson) writes: [EMAIL PROTECTED] wrote: If I may recommend an alternative, print \033[H\033[J the ansi sequence to clear the screen. Or so you would hope (however, that is *not* what you have listed!). Unfortunately, it is poor practice to hard code such sequences. Instead the proper sequence should be obtained from the appropriate database (TERMINFO or TERMCAP), and the easy way to do that is, tput clear (Or clear.) On the other hand, I think it's been at least a decade since I've used a terminal or emulator that's not VT100-compatible (i.e., accepts ANSI control sequences). Of course, I'll run into one the day after I start writing code that depends on that assumption. -- Keith Thompson (The_Other_Keith) [EMAIL PROTECTED] http://www.ghoti.net/~kst San Diego Supercomputer Center * http://users.sdsc.edu/~kst We must do something. This is something. Therefore, we must do this. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to run script from interpreter?
On 5/28/14 10:22 PM, Steven D'Aprano wrote: If you want to use python as a shell-glue you can try using system. from os import system def function_name([parms]) blah blah rc = system(your_script_name) os.system is cool for quick and dirty calls to an external command. But for serious work, the subprocess module is better. ... yup, particularly for non trivial network related stuff. Neither here nor there, but I just learned the ; character command today for the Julia REPL, and got to thinking that python should have a similar way for the REPL to drop into shell mode for system commands. So, I might code a clear screen in python: def cls() rc = system(clear) or in Julia function cls() run(`clear`) end ... but on Julia we can also do this: ; clear On the Julia REPL the ; character drops the julia prompt into shell. I think the IDLE REPL should have a system shell mode. What say you? marcus -- https://mail.python.org/mailman/listinfo/python-list
[issue43432] Add function `clear` to the `os` module
parsa mpsh added the comment: Well, some times we are writing a flexible Text ui program. we may use `clear` lot of times. This should be used when we haven't any valuable data on the screen. Also, who that uses this function, knows this will clear valuable data :). Sometimes also i use this command. but every time a should check that is this operation windows or not, to determine `clear` or `cls`. I think this is very helpful for making this easier. The best feature of Python is its simplicity and power. More helper functions to make the code shorter and knowable, is a good thing for Python. Also about the Windows API instead of `cls`, i don't know more thing. But i think its not a big problem and `cls` works. -- ___ Python tracker <https://bugs.python.org/issue43432> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37745] 3.8b3 - windows install gui/ inconsistent options
New submission from Christopher Brousseau : When installing 3.8.0b3 64-bit into Win 10 using the gui following the `customize installation` path, there are duplicate and inconsistent options on three different screens for the `install for all users` checkbox. Observed Behavior: 1. first screen (Install Python) - `install launcher for all users` is marked as checked as default 2. second screen (Optional Features) - 2.1 `for all users` is also marked as checked if first screen marked. if second screen marked - this is unchecked. 2.2 layout of this checkbox is above a comment that relates only to the "py launcher" checkbox. would be more clear for user if `for all users` was located below "py launcher", or removed from this screen (per note below) 3. third screen (Advanced Options) - `Install for all users` is UNchecked in all cases, even if first & second screens are checked. Expected Behavior: 1. if first screen is checked, all follow on screens are also checked 2. feature options only appear on one screen, or at a minimum, checkbox label is exactly the same on all screens Additional Questions for the team: 1. Should all install customizations be removed from first screen, set as default options and just listed as descriptions under the `Install Now` default? 2. Should `for all users` option be removed from the 2nd screen (Optional Features)? It seems more like an "advanced option" than a feature. Screenshots (this site appears to only allow one file) first: https://imgur.com/a/0a45CBh second: https://imgur.com/a/6ZV16bV third: https://imgur.com/a/stRTh25 Link to binary used for this: https://www.python.org/ftp/python/3.8.0/python-3.8.0b3-amd64.exe -- components: Installation, Windows files: python_3.8b3_screen02_optional_features_2019-08-02_9-56-02.png messages: 348907 nosy: Christopher Brousseau, paul.moore, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: 3.8b3 - windows install gui/ inconsistent options type: behavior versions: Python 3.8 Added file: https://bugs.python.org/file48527/python_3.8b3_screen02_optional_features_2019-08-02_9-56-02.png ___ Python tracker <https://bugs.python.org/issue37745> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: os.system('cls')
On 25 dec 2008, at 11:22, Dennis van Oosterhout wrote: Hi there! I was searching for a way to clear the 'DOS screen'/ command screen etc. and found that os.system('cls') works for this. I was just wondering where I can find al the commands which can be used for os.system(). I searched with google but I didn't find an answer. In the official python tutorial it says os.system('command') executes the command, but it doesn't say which commands exist (or I'm just blind). Does anyone have an answer for this question? Thanks, Devilly Hey Deville, os.system() executes commands that you usually use in a shell outside python. so in the case of you being a windows user, you replace 'command' with any DOS command. gr Arno -- http://mail.python.org/mailman/listinfo/python-list
RE: os.system('cls')
Hi Dennis, print dir(os.system) print os.__dict__ might help Bye, Ron. From: Dennis van Oosterhout [mailto:de.slotenzwem...@gmail.com] Sent: Thursday, December 25, 2008 12:22 To: python-list@python.org Subject: os.system('cls') Hi there! I was searching for a way to clear the 'DOS screen'/command screen etc. and found that os.system('cls') works for this. I was just wondering where I can find al the commands which can be used for os.system(). I searched with google but I didn't find an answer. In the official python tutorial it says os.system('command') executes the command, but it doesn't say which commands exist (or I'm just blind). Does anyone have an answer for this question? Thanks, Devilly -- http://mail.python.org/mailman/listinfo/python-list
Re: os.system('cls')
Depends on what operating system you are using. The list of possible commands would be unbounded, if not truly infinite. From: Dennis van Oosterhout [mailto:de.slotenzwem...@gmail.com] Hi there! I was searching for a way to clear the 'DOS screen'/command screen etc. and found that os.system('cls') works for this. I was just wondering where I can find al the commands which can be used for os.system(). I searched with google but I didn't find an answer. In the official python tutorial it says os.system('command') executes the command, but it doesn't say which commands exist (or I'm just blind). Does anyone have an answer for this question? -- http://mail.python.org/mailman/listinfo/python-list
Re: repair modify uninstall
On 2020-06-11, Terry Reedy wrote: > >> Indeed. Is the file name not clear that it's an installer? > > No. python-3.8.3-amd64.exe, which is typical naming for install files. > > I opened https://bugs.python.org/issue40948 and suggested adding > '-setup' or '-install', An excellent suggestion. When I build .exe installers, I always end the name in '-setup'. Everybody seems to understand that, but my audience is probably smaller and a bit more tech-savvy that that of the Python audience. > as well as instructions on the initial screen for existing installs, > and, if not present, the final screen for new installs. Thanks for filing that bug. -- Grant -- https://mail.python.org/mailman/listinfo/python-list