On 19 September 2016 at 21:35, João Matos <jcrma...@gmail.com> 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 cls because it is normally used to mean class.
> I use Windows and tested a simple (possibly not the best of course) solution
> that seems to work in REPL (but not in IDLE).
> import os
> import sys
> def clear():
>     if sys.platform == 'win32':
>         os.system('cls')
>     else:
>         os.system('clear')

Ah, I think people had misunderstood your proposal of a "command" as
something where you didn't have to type the parentheses. I know I did.
If you're OK with what you type at the REPL being

    >>> clear()

then that's much easier to achieve. For example, if you install click
(https://pypi.python.org/pypi/click) you can just add "from click
import clear" at the start of your REPL session (or add it to your
PYTHONSTARTUP if you want it always available) and you're done.

Adding similar functionality to the stdlib somewhere (for example os
or shutil - I doubt it's going to get accepted as a builtin) isn't
inconceivable. I'm still not sure the benefit is sufficient to be
worthwhile (it might be more useful to just bite the bullet and bundle
one of the many curses variants for Windows into the distribution, and
make the curses module cross-platform once and for all, rather than
implementing individual bits of functionality) but if someone wanted
to contribute a patch on the tracker, it might be accepted.

Python-ideas mailing list
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to