On Sun, Dec 27, 2020 at 02:00:00PM +1100, Chris Angelico wrote:

> This is actually the exact part that I think should *not* happen, for
> several reasons:
> 
> 1) Stuff that exists interactively and doesn't exist in a script is a
> barrier to that migration. I don't think this feature justifies that
> barrier.

It will still exist in a script, you can still import it from the os 
module if you care about supporting cases where site.py doesn't get run.

This is no different from `exit`:

    [steve ~]$ python3.9 -c "print(exit)"
    Use exit() or Ctrl-D (i.e. EOF) to exit

    [steve ~]$ python3.9 -S -c "print(exit)"
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    NameError: name 'exit' is not defined

Well, actually, it will be slightly different: the pseudo-builtin `exit` 
is a special object created for interactive use, it's not the same as 
`sys.exit`. Whereas I invisage that the interactive `clear` will be 
identical (same object) as `os.clear`.


> 2) The builtins are already incredibly busy, and this, again, doesn't
> justify being one

It's not an *actual* builtin, it's just monkey-patched into the 
builtins by site.py.

I don't think there is sufficient justification for this to make it a 
genuine builtin like `len` or `iter`, but I think loading it into the 
builtin namespace for the convenience of the user is plenty justified.

Having clear available immediately in the interactive interpreter is 
certainly more useful than having the licence, credits and copyright 
notice, and yet there they are. Probably the three least used builtins 
ever.


> 3) Beginners already have to learn about importing (eg "from math
> import sin") and this is just one more importable.

As far as I can tell, every language that supports a clear/cls command, 
from old BASIC to modern shells, makes it available immediately. You 
don't have to adjust the PATH in bash to get access to clear, it just 
works.

Think of this as the companion to print. If you think about Python as an 
interactive interpreter, its weird to have print, help, quit available 
but not clear. Its a fairly fundamental interactive command.


> > So that's the easy part: just agree with me and import it in site.py,
> > wherever it happens to come from. *wink*
> 
> This is python-ideas! We don't "just agree" here, we argue! Even if we
> don't have to!

I disagree!

*wink*


-- 
Steve
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/XBXNLWGXCTSM5BQCNZQNU5DFXVI7L4TK/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to