
@Paul Moor, I agree with you. Personally, I'd rather not use it, and if it was used in an importable module I'd claim it was bad practice. But in general I don't think there is a right answer of if you *should *or not. I think it is valid for personal preferences to vary here. If this is something someone forgets to do a lot (and everyone has their own personal quirks about what's hard/easy for them to remember), then it could be annoying to the point where this feature could really help them. But yes, in most cases I'd rather not use it, and I would get peeved if someone's code they advertised as reusable used this (but then again I also get peeved when people execute print statements at import time). On Fri, Oct 16, 2020 at 5:02 PM Paul Moore <p.f.moore@gmail.com> wrote:
On Fri, 16 Oct 2020 at 20:43, Jonathan Crall <erotemic@gmail.com> wrote:
@Chris Angelico If you are more application focused, or trying to get a
scientific result, and you don't care too much about the reusability of your scripts, then I can see the validity of this use case. But I would not want to install a module on pypi that made use of this. From a software perspective this is 100% bad practice, but from a practitioner perspective --- and there are a lot of practitioners that only use Python as a tool (like a DSL) --- I can see wanting it.
So, that's the question: does the Python stdlib want to let you do this?
Will the number of software engineers who use this incorrectly outweigh the number of people who seem to want this for a valid reason? I'm not sure what the answer is.
FWIW executing `print('\x1b[H\x1b[2J\x1b[3J')` in my IPython terminal
cleared the screen.
Why would you want to put this in your script, so that you have no choice (short of editing the script) as to whether it happens? Surely better to clear your terminal from the command prompt *before* running your script? Yes, you can forget, but I'd rather forget occasionally than lose essential data because I ran a script that I'd forgotten has an os.clear() at the top...
I suspect Guido's right, it's asked for often enough, and fiddly enough to write, that adding it is a net gain. But I'd be very unlikely to use it myself, and I'd strongly advise people against using it if asked.
Paul
-- -Dr. Jon Crall (him)