Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-10-04 Thread eryk sun
On Tue, Oct 4, 2016 at 2:22 PM, Random832 wrote: > On Wed, Sep 28, 2016, at 23:36, Chris Angelico wrote: >> On Thu, Sep 29, 2016 at 12:04 PM, Steven D'Aprano >> wrote: >> > (Also, it seems a shame that Ctrl-D is EOF in Linux and Mac, but Windows >> > is Ctrl-Z + Return. Can that be standardized t

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-10-04 Thread Random832
On Wed, Sep 28, 2016, at 23:36, Chris Angelico wrote: > On Thu, Sep 29, 2016 at 12:04 PM, Steven D'Aprano > wrote: > > (Also, it seems a shame that Ctrl-D is EOF in Linux and Mac, but Windows > > is Ctrl-Z + Return. Can that be standardized to Ctrl-D everywhere?) > > Sadly, I suspect not. If you'

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-29 Thread eryk sun
On Thu, Sep 29, 2016 at 7:12 AM, João Matos wrote: > What is your Windows version? Are you trying on the cmd.exe console or PS? Are you talking about PowerShell ISE? That doesn't work for interactive console programs such as Python's REPL shell. Otherwise, FYI, there is no such thing as a cmd.ex

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-29 Thread Stephan Houben
Hi JM, Yes indeed, I have that installed. I was unaware it activates itself in the normal interpreter. (I have it installed because IPython asks for it). Stephan 2016-09-29 9:59 GMT+02:00 João Matos : > Hello, > > You must have pyreadline installed (it isn't installed in the default > CPython d

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-29 Thread Stephan Houben
Hi JM, Windows 7 Enterprise "Microsoft Windows [Version 6.1.7601]" I am running Python directly from the shortcut created on installation. But starting it from cmd.exe has the same effect. Codepage is 437 , this may be relevant? I just tried it on a Windows 10 PC, there it has the same effect.

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-29 Thread João Matos
Hello, I tried on Python 2.7.10 and Python 3.5.2 and Ctrl-L doesn't work on both. I tried on 2 PCs with Windows 7 and none of them worked. What is your Windows version? Are you trying on the cmd.exe console or PS? Best regards, JM quinta-feira, 29 de Setembro de 2016 às 08:09:13 UTC+1, Stepha

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-29 Thread João Matos
Hello, You must have pyreadline installed (it isn't installed in the default CPython distribution). Best regards, JM On 29-09-2016 08:56, Stephan Houben wrote: Hi JM, Windows 7 Enterprise "Microsoft Windows [Version 6.1.7601]" I am running Python directly from the shortcut created on in

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-29 Thread eryk sun
On Thu, Sep 29, 2016 at 7:08 AM, Stephan Houben wrote: > > I just tried with this official Python binary: > Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit > (Intel)] on win32 > > and CTRL-L for sure does clear the window. It just doesn't then move the > prompt to the

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-29 Thread Paul Moore
On 29 September 2016 at 08:08, Stephan Houben wrote: > I just tried with this official Python binary: > Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit > (Intel)] on win32 > > and CTRL-L for sure does clear the window. It just doesn't then move the > prompt to the top,

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-29 Thread Stephan Houben
Hi all, I just tried with this official Python binary: Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit (Intel)] on win32 and CTRL-L for sure does clear the window. It just doesn't then move the prompt to the top, so you end up with a bunch of empty lines, followed by

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-28 Thread João Matos
Hello, Yes, Ctrl-L doesn't clear the screen on Windows. Making Ctrl-L clear the screen would be a good solution (no need for a clear screen command). Best regards, JM quinta-feira, 29 de Setembro de 2016 às 03:06:26 UTC+1, Steven D'Aprano escreveu: > On Tue, Sep 27, 2016 at 10:05:16AM -0700

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-28 Thread אלעזר
"Bash on Ubuntu on windows" responds to CTRL+D just fine. I don't really know how it works, but it looks like it is based on the Windows terminal emulator. Elazar בתאריך יום ה׳, 29 בספט' 2016, 06:36, מאת Chris Angelico ‏: > On Thu, Sep 29, 2016 at 12:04 PM, Steven D'Aprano > wrote: > > (Also, i

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-28 Thread Chris Angelico
On Thu, Sep 29, 2016 at 12:04 PM, Steven D'Aprano wrote: > (Also, it seems a shame that Ctrl-D is EOF in Linux and Mac, but Windows > is Ctrl-Z + Return. Can that be standardized to Ctrl-D everywhere?) Sadly, I suspect not. If you're running in the default Windows terminal emulator (the one a nor

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-28 Thread Oleg Broytman
On Thu, Sep 29, 2016 at 12:04:28PM +1000, Steven D'Aprano wrote: > (Also, it seems a shame that Ctrl-D is EOF in Linux and Mac, but Windows > is Ctrl-Z + Return. Can that be standardized to Ctrl-D everywhere?) I don't think consistency should go that far. Consistency inside the platform is m

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-28 Thread Steven D'Aprano
On Tue, Sep 27, 2016 at 10:05:16AM -0700, João Matos wrote: > Hello, > > > It doesn't work in Windows. What is "it"? Are you talking about Ctrl-L to clear the screen? Perhaps we should start by adding Ctrl-L as a standard way to clear the Python REPL, in the same way that Ctrl-C is the standa

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-27 Thread João Matos
Hello, It doesn't work in Windows. Best regards, JM terça-feira, 27 de Setembro de 2016 às 16:40:42 UTC+1, Dennis Brakhane via Python-ideas escreveu: > I don't know if it works on Windows, but at least in Linux pressing > Ctrl-L will do exactly what you describe (as long as the REPL uses

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-27 Thread Dennis Brakhane via Python-ideas
I don't know if it works on Windows, but at least in Linux pressing Ctrl-L will do exactly what you describe (as long as the REPL uses readline) On 17.09.2016 12:51, João Matos wrote: > Hello, > > I would like to suggest adding a clear command (not function) to Python. > It's simple purpose would

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-20 Thread Greg Ewing
Terry Reedy wrote: In the default mode with user code executed in a separate no-window process, there is currently no way for the child process to know the current size of Shell's tk text window in the parent process. On unix it should be possible to let the child know if it's connected throu

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-20 Thread Terry Reedy
On 9/20/2016 9:31 AM, Steven D'Aprano wrote: On Mon, Sep 19, 2016 at 06:18:38AM -0400, Terry Reedy wrote: On 9/19/2016 4:31 AM, Paul Moore wrote: shutil.get_terminal_size() is available on all platforms. On windows, it works with Command Prompt and PowerShell but fails in IDLE, as it must.

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-20 Thread Steven D'Aprano
On Mon, Sep 19, 2016 at 06:18:38AM -0400, Terry Reedy wrote: > On 9/19/2016 4:31 AM, Paul Moore wrote: > > >shutil.get_terminal_size() is available on all platforms. > > On windows, it works with Command Prompt and PowerShell but fails in > IDLE, as it must. Why "must" it fail? What is it abou

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-20 Thread Michel Desmoulin
+1 for this. I regularly miss this feature. Le 17/09/2016 à 13:12, João Matos a écrit : > Hello, > > In other interpreted programming languages the clear screen command > (whatever it is) also does not clear the session. > It just clears the screen clutter. > > As I said, this would be very usef

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-20 Thread Chris Angelico
On Tue, Sep 20, 2016 at 6:20 PM, Paul Moore wrote: > There > have been occasional deviations from this (for example, the "as" in > "import foo as bar" was, for a time, only a keyword in that specific > context) but I don't believe any of them survived long-term. async and await are similarly cont

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-20 Thread Paul Moore
On 20 September 2016 at 08:57, אלעזר wrote: > This is since in Python there are no contextual keywords (like "override" > and "final" in C++). I remember encountering error in a Django project where > accessing u.pass was a syntax error, but there *was* a field "pass" in u and > they had to resort

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-20 Thread אלעזר
On Tue, Sep 20, 2016 at 4:56 AM Steven D'Aprano wrote: > On Mon, Sep 19, 2016 at 01:35:53PM -0700, João Matos wrote: > > Hello, > > > > I don't see why creating a clear command would interfere with > dict.clear() > > which is a function/method. > > For the same reason that you can't have a method

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-20 Thread João Matos
Hello, You are correct. Thanks for the explanation. Best regards, JM terça-feira, 20 de Setembro de 2016 às 02:56:57 UTC+1, Steven D'Aprano escreveu: > On Mon, Sep 19, 2016 at 01:35:53PM -0700, João Matos wrote: > > Hello, > > > > I don't see why creating a clear command would interfere w

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-19 Thread Steven D'Aprano
On Mon, Sep 19, 2016 at 01:35:53PM -0700, João Matos wrote: > Hello, > > I don't see why creating a clear command would interfere with dict.clear() > which is a function/method. For the same reason that you can't have a method called foo.while or foo.if or foo.raise. If clear is a "command" (a

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-19 Thread Paul Moore
On 19 September 2016 at 21:35, João Matos wrote: > Hello, > > I don't see why creating a clear command would interfere with dict.clear() > which is a function/method. > > Although my first idea was a clear command, I have no problem if it is a > clear() function from site.py. > > I didn't suggest

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-19 Thread João Matos
Hello, I don't see why creating a clear command would interfere with dict.clear() which is a function/method. Although my first idea was a clear command, I have no problem if it is a clear() function from site.py. I didn't suggest cls because it is normally used to mean class. I use Windows a

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-19 Thread eryk sun
On Mon, Sep 19, 2016 at 3:07 PM, Oleg Broytman wrote: >[Ctrl+D] also recognized as EOF only at the start of an input. You're right. I was mixing it up with sys.stdin.buffer.raw.read(), for which Ctrl+D can end the read anywhere if entered twice. Having to enter it twice may be a bug, because

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-19 Thread Zachary Ware
On Mon, Sep 19, 2016 at 9:45 AM, eryk sun wrote: > On Mon, Sep 19, 2016 at 1:12 PM, Paul Moore wrote: >> By the way - if you're on a system with readline support included with >> Python, GNU readline apparently has a binding for clear-screen >> (CTRL-L) so you may well have this functionality alr

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-19 Thread Oleg Broytman
On Mon, Sep 19, 2016 at 02:45:53PM +, eryk sun wrote: > The pInputControl parameter can also be used to implement Unix-style > Ctrl+D to end a read anywhere on a line, whereas the classic > [Ctrl+Z][Enter] has to be entered at the start of a line. [Ctrl+D] also recognized as EOF only at th

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-19 Thread eryk sun
On Mon, Sep 19, 2016 at 1:12 PM, Paul Moore wrote: > By the way - if you're on a system with readline support included with > Python, GNU readline apparently has a binding for clear-screen > (CTRL-L) so you may well have this functionality already (I don;'t use > Unix or readline, so I can't comme

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-19 Thread Paul Moore
On 19 September 2016 at 13:10, Paul Moore wrote: > > For this particular suggestion, though, I don't think that's the case. > I think it's going to either be something that's accepted into the > stdlib, or something that's rejected as too platform-specific or messy > to standardise, and people sho

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-19 Thread Chris Angelico
On Mon, Sep 19, 2016 at 9:56 PM, Steven D'Aprano wrote: > On Mon, Sep 19, 2016 at 06:38:00PM +1000, Chris Angelico wrote: > >> Sounds good to me. This is definitely sounding complicated and messy >> enough to justify (a) writing a function to clear the screen, and (b) >> testing that function thor

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-19 Thread Paul Moore
On 19 September 2016 at 12:56, Steven D'Aprano wrote: > > For relatively small pieces of functionality, if it is useful enough, we > should just add it to the std lib, and if it isn't, we should just say > it isn't useful enough. We shouldn't condemn supporters of the idea to > this false hope tha

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-19 Thread Steven D'Aprano
On Mon, Sep 19, 2016 at 06:38:00PM +1000, Chris Angelico wrote: > Sounds good to me. This is definitely sounding complicated and messy > enough to justify (a) writing a function to clear the screen, and (b) > testing that function thoroughly as a PyPI module before pushing > anything into the stdl

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-19 Thread Terry Reedy
On 9/19/2016 4:31 AM, Paul Moore wrote: shutil.get_terminal_size() is available on all platforms. On windows, it works with Command Prompt and PowerShell but fails in IDLE, as it must. In the absence of knowledge, it guesses the default of 80 x 24 (as documented). AFAIK, there is no way wh

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-19 Thread Chris Angelico
On Mon, Sep 19, 2016 at 6:31 PM, Paul Moore wrote: > On 19 September 2016 at 03:40, Chris Angelico wrote: >> On Mon, Sep 19, 2016 at 12:32 PM, Steven D'Aprano >> wrote: >>> (The fallback if all else fails is easy: get the height of the terminal, >>> in lines, and print that many blank lines.) >

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-19 Thread Paul Moore
On 19 September 2016 at 03:40, Chris Angelico wrote: > On Mon, Sep 19, 2016 at 12:32 PM, Steven D'Aprano wrote: >> (The fallback if all else fails is easy: get the height of the terminal, >> in lines, and print that many blank lines.) > > Assuming you can get the height in lines. Have you tried t

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-18 Thread Stephen J. Turnbull
Chris Angelico writes: > On Mon, Sep 19, 2016 at 12:32 PM, Steven D'Aprano > wrote: > > (The fallback if all else fails is easy: get the height of the terminal, > > in lines, and print that many blank lines.) > > Assuming you can get the height in lines. Have you tried that in the > defau

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-18 Thread Chris Angelico
On Mon, Sep 19, 2016 at 12:32 PM, Steven D'Aprano wrote: > (The fallback if all else fails is easy: get the height of the terminal, > in lines, and print that many blank lines.) Assuming you can get the height in lines. Have you tried that in the default Windows shell? I don't think tcgetattr wor

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-18 Thread Steven D'Aprano
On Sat, Sep 17, 2016 at 11:51:16AM +0100, João Matos wrote: > Hello, > > I would like to suggest adding a clear command (not function) to Python. While technically "clear" could be a command, I think it should not be. First off, making clear a reserved keyword, and a statement, like print in Py

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-17 Thread Terry Reedy
On 9/17/2016 6:51 AM, João Matos wrote: Hello, I would like to suggest adding a clear command (not function) to Python. It's simple purpose would be to clear the REPL screen, leaving the >>> prompt at the top left of the screen. This is something very basic but also very useful for newbies lear

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-17 Thread eryk sun
On Sat, Sep 17, 2016 at 1:15 PM, Wes Turner wrote: > !cls #windows cmd's built-in cls command doesn't clear just the screen, like a VT100 \x1b[1J. It clears the console's entire scrollback buffer. Unix `clear` may also work like that. With GNOME Terminal in Linux, `clear` leaves a single screen

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-17 Thread João Matos
Hello, I searched and found several possible solutions to clear the screen in the CPython REPL, but all are, in my opinion, complex for a newbie. The existence of a clear command would be a simple and obvious, therefore accessible to newbies. Best regards, JM On 17-09-2016 14:34, eryk sun

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-17 Thread João Matos
Hello, I know about those IPython commands and I searched and found several possible solutions to clear the screen in the CPython REPL, but all are, in my opinion, complex for a newbie. The existence of a clear command would be simple and obvious, therefore accessible to newbies. Best regar

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-17 Thread eryk sun
On Sat, Sep 17, 2016 at 11:11 AM, João Matos wrote: >On 17-09-2016 12:07, Oleg Broytman wrote: >> >> Pressing [Ctrl]+[L] works for me. > > Doesn't work on Windows. Windows 10 added VT100 support to the console, so you can create a little cls() function to clear the screen: cls = lambda:

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-17 Thread Wes Turner
With IPython, there are a number of ways to reset the terminal display: clear # %clear !cls #windows !reset - http://stackoverflow.com/questions/6892191/clearing-the-screen-in-ipython - Ctrl-L is a readline binding - http://pythonhosted.org/pyreadline/usage.html#pyreadline-with-python-

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-17 Thread João Matos
Hello, In other interpreted programming languages the clear screen command (whatever it is) also does not clear the session. It just clears the screen clutter. As I said, this would be very useful for newbies, which don't know anything about usercustomize or sitecustomize. Best regards, J

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-17 Thread João Matos
Hello, Doesn't work on Windows. Best regards, JM On 17-09-2016 12:07, Oleg Broytman wrote: Hi! On Sat, Sep 17, 2016 at 11:51:16AM +0100, Jo??o Matos wrote: Hello, I would like to suggest adding a clear command (not function) to Python. Pressing [Ctrl]+[L] works for me. Best rega

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-17 Thread Oleg Broytman
Hi! On Sat, Sep 17, 2016 at 11:51:16AM +0100, Jo??o Matos wrote: > Hello, > > I would like to suggest adding a clear command (not function) to Python. Pressing [Ctrl]+[L] works for me. > Best regards, > JM Oleg. -- Oleg Broytmanhttp://phdru.name/p...@phdru.na

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-17 Thread Chris Angelico
On Sat, Sep 17, 2016 at 8:51 PM, João Matos wrote: > I would like to suggest adding a clear command (not function) to Python. > It's simple purpose would be to clear the REPL screen, leaving the >>> > prompt at the top left of the screen. > > This is something very basic but also very useful for n

[Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-17 Thread João Matos
Hello, I would like to suggest adding a clear command (not function) to Python. It's simple purpose would be to clear the REPL screen, leaving the >>> prompt at the top left of the screen. This is something very basic but also very useful for newbies learning Python from the REPL. After some