On Sun, Dec 27, 2020 at 4:26 PM Steven D'Aprano <st...@pearwood.info> wrote: > > 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
Oh, sorry, my bad. Withdraw point 1 then. > > 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. But how's that different? Either it's a builtin or it's not. How it gets there is mostly irrelevant, other than to make a separate monkeypatching layer (such as would need to be done by Idle) more complicated. > 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. Ohh, do you mean how some functions are intrinsic parts of the interpreter? I'm not talking about that; I'm talking about how it's accessed, ie the namespacing. > 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. Perhaps, but they have legal reasons for existing. > > 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. Old BASIC didn't *have* an import feature (at least, the BASICs that I used didn't), and modern shells have a ton of shell-related stuff in their "builtins" but nothing else, because that's their focus. You can't, for instance, do trig functions in the basic shell, nor even arithmetic, because those aren't builtins. Different environments focus on different things. > 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. I don't actually agree. Having the ability to print? Yes, that's fundamental. Being able to quit? Of course you need that. But there's no cursor movement function in the builtins, nor is there a "show this image" function, nor "display this web page", or various things like that. In terms of console actions, the two most fundamental are print and input, and we get both of those. Everything else has to justify itself in terms of utility and convenience; getting documentation, for instance, could easily have been buried away in a module, but it is *incredibly* helpful to be able to pull up help(x) without an import. We don't need a full set of cursor movement and screen manipulation features as builtins - that's the job of curses. I don't think we really need screen clearing that way either, particularly as the obvious name "clear" is also used in various other contexts, such as lists and dicts. (How confusing would it be to say clear(lst) instead of lst.clear() and then try to figure out what's going on?) > > > 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* > Is this one of those cases where we "agree to disagree"? *wink* ChrisA _______________________________________________ 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/GNCXENABIDMRKCH45DSPCOWBCPMTC7HG/ Code of Conduct: http://python.org/psf/codeofconduct/