[Python-ideas] Re: New feature

2020-10-16 Thread Michael Smith
On Fri, Oct 16, 2020 at 22:42 Steven D'Aprano wrote: > On Fri, Oct 16, 2020 at 10:28:20PM -0400, David Mertz wrote: > > On Fri, Oct 16, 2020, 10:16 PM Steven D'Aprano > > > > > I think that if we go ahead with this, we shouldn't allow lack > > > of support for screen and/or tmux to stand in the

[Python-ideas] Re: New feature

2020-10-16 Thread David Mertz
On Fri, Oct 16, 2020, 10:43 PM Steven D'Aprano > > What manner of savages run a terminal without a multiplexer? :-) > I understand using screen or tmux when ssh'ing into a remote machine, but > what advantage are they when you are using the local machine via a GUI? > It was definitely

[Python-ideas] Re: New feature

2020-10-16 Thread Steven D'Aprano
On Fri, Oct 16, 2020 at 10:28:20PM -0400, David Mertz wrote: > On Fri, Oct 16, 2020, 10:16 PM Steven D'Aprano > > > I think that if we go ahead with this, we shouldn't allow lack > > of support for screen and/or tmux to stand in the way. A 99% solution is > > better than a 0% solution :-) > > >

[Python-ideas] Re: New feature

2020-10-16 Thread David Mertz
On Fri, Oct 16, 2020, 10:16 PM Steven D'Aprano > I think that if we go ahead with this, we shouldn't allow lack > of support for screen and/or tmux to stand in the way. A 99% solution is > better than a 0% solution :-) > What manner of savages run a terminal without a multiplexer? :-)

[Python-ideas] Re: New feature

2020-10-16 Thread Steven D'Aprano
On Fri, Oct 16, 2020 at 09:53:35PM -0400, David Mertz wrote: > On Fri, Oct 16, 2020 at 9:36 PM Steven D'Aprano wrote: > > > > Well, in terminals like bash, `clear` does not really delete the > > > previous input. It simply move the scroll so the first line of the > > > input is the current

[Python-ideas] Re: New feature

2020-10-16 Thread David Mertz
On Fri, Oct 16, 2020 at 9:36 PM Steven D'Aprano wrote: > > Well, in terminals like bash, `clear` does not really delete the > > previous input. It simply move the scroll so the first line of the > > input is the current input. > > That's not actually correct: in bash, `clear` actually deletes

[Python-ideas] Re: New feature

2020-10-16 Thread Steven D'Aprano
On Fri, Oct 16, 2020 at 11:30:56PM +0200, Marco Sulla wrote: > Well, in terminals like bash, `clear` does not really delete the > previous input. It simply move the scroll so the first line of the > input is the current input. That's not actually correct: in bash, `clear` actually deletes the

[Python-ideas] Re: New feature

2020-10-16 Thread Steven D'Aprano
On Sat, Oct 17, 2020 at 05:44:12AM +1100, Chris Angelico wrote: > On Sat, Oct 17, 2020 at 5:40 AM Jonathan Crall wrote: > > > > I just want to point out that I can think of a valid use case for `clf`. > > I'm not sure if it was mentioned. > > > > In the case where you have a script that produces

[Python-ideas] Re: New feature

2020-10-16 Thread Marco Sulla
Well, in terminals like bash, `clear` does not really delete the previous input. It simply move the scroll so the first line of the input is the current input. Maybe the REPL can emulate this in some way. ___ Python-ideas mailing list --

[Python-ideas] Re: New feature

2020-10-16 Thread Ethan Furman
On 10/13/20 4:46 PM, Steven D'Aprano wrote: And I [clear my screen] frequently, in both Python and bash. Because I never remember the name of the bash command to do it (cls or clear?), and Python doesn't have one, I just hold down the Enter key for a couple of seconds until there's no clutter

[Python-ideas] Re: New feature

2020-10-16 Thread Jonathan Crall
@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

[Python-ideas] Re: New feature

2020-10-16 Thread Rob Cliffe via Python-ideas
On 16/10/2020 22:02, Paul Moore wrote: On Fri, 16 Oct 2020 at 20:43, Jonathan Crall 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

[Python-ideas] Re: New feature

2020-10-16 Thread Paul Moore
On Fri, 16 Oct 2020 at 20:43, Jonathan Crall 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

[Python-ideas] Re: New feature

2020-10-16 Thread Jonathan Crall
@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

[Python-ideas] Re: New feature

2020-10-16 Thread Chris Angelico
On Sat, Oct 17, 2020 at 5:40 AM Jonathan Crall wrote: > > I just want to point out that I can think of a valid use case for `clf`. I'm > not sure if it was mentioned. > > In the case where you have a script that produces a lot of output, a common > task might be scrolling to the beginning to

[Python-ideas] Re: New feature

2020-10-16 Thread Jonathan Crall
I just want to point out that I can think of a valid use case for `clf`. I'm not sure if it was mentioned. In the case where you have a script that produces a lot of output, a common task might be scrolling to the beginning to check an output. If your screen was not fresh, and you had a lot of

[Python-ideas] Re: New feature

2020-10-16 Thread David Mertz
I agree with Guido here. Although I really don't care about the capability myself, it feels like enough people do want a "clear screen" function... and from the discussion, in feels like there are a LOT of variations in how to do it across different operating systems, OS versions, terminals,

[Python-ideas] Re: New feature

2020-10-16 Thread Rob Cliffe via Python-ideas
On 16/10/2020 13:55, Chris Angelico wrote: On Fri, Oct 16, 2020 at 11:08 PM Rob Cliffe wrote: On 16/10/2020 11:59, Chris Angelico wrote: On Fri, Oct 16, 2020 at 8:21 PM Rob Cliffe via Python-ideas wrote: On 13/10/2020 23:35, Guido van Rossum wrote: Can one of the educators on the list

[Python-ideas] Re: New feature

2020-10-16 Thread Eryk Sun
On 10/16/20, Barry Scott wrote: > > I find that you have to do this to turn on ANSI processing in CMD.EXE on > Window 10 and I assume earlier Windwows as wel: You mean the console-session host (conhost.exe). This has nothing to do with the CMD shell. People often confuse CLI shells (CMD,

[Python-ideas] Re: New feature

2020-10-16 Thread Barry Scott
> On 16 Oct 2020, at 14:44, Rob Cliffe via Python-ideas > wrote: > > > > On 16/10/2020 13:55, Chris Angelico wrote: >> >>> I do precisely that in many of my programs for e.g. single-line progress >>> displays. >>> But for multi-line output I don't know of any way to move the cursor >>>

[Python-ideas] Re: New feature

2020-10-16 Thread Rob Cliffe via Python-ideas
On 16/10/2020 13:55, Chris Angelico wrote: I do precisely that in many of my programs for e.g. single-line progress displays. But for multi-line output I don't know of any way to move the cursor back up. I work in Windows 10. Try \x1b[A to move up a line, should work. ChrisA Got it

[Python-ideas] Re: New feature

2020-10-16 Thread Joao S. O. Bueno
On Fri, 16 Oct 2020 at 08:00, Chris Angelico wrote: > On Fri, Oct 16, 2020 at 8:21 PM Rob Cliffe via Python-ideas > wrote: > > > > > > > > On 13/10/2020 23:35, Guido van Rossum wrote: > > > Can one of the educators on the list explain why this is such a > > > commonly required feature? I

[Python-ideas] Re: New feature

2020-10-16 Thread Chris Angelico
On Fri, Oct 16, 2020 at 11:08 PM Rob Cliffe wrote: > > > > On 16/10/2020 11:59, Chris Angelico wrote: > > On Fri, Oct 16, 2020 at 8:21 PM Rob Cliffe via Python-ideas > > wrote: > >> > >> > >> On 13/10/2020 23:35, Guido van Rossum wrote: > >>> Can one of the educators on the list explain why this

[Python-ideas] option to keep TemporaryDirectory

2020-10-16 Thread David Kolovratník
Hi Everyone, When adding debug option to a program I find useful to keep temporary stuff. tempfile.NamedTemporaryFile has option delete defaulting to True. What about adding such option to tempfile.TemporaryDirectory as well? It would be just a minor modification in Lib/tempfile.py. What do you

[Python-ideas] Re: New feature

2020-10-16 Thread Rob Cliffe via Python-ideas
On 16/10/2020 11:59, Chris Angelico wrote: On Fri, Oct 16, 2020 at 8:21 PM Rob Cliffe via Python-ideas wrote: On 13/10/2020 23:35, Guido van Rossum wrote: Can one of the educators on the list explain why this is such a commonly required feature? I literally never feel the need to clear

[Python-ideas] Re: Weakrefs for lru_cache?

2020-10-16 Thread Antoine Pitrou
On Fri, 16 Oct 2020 12:38:49 +0300 Ram Rachum wrote: > Well, I can also write a decorator that does lru_cache, but there are a lot > of advantages that it's available in the standard library... But the standard libary doesn't have to contain every utility function on Earth. And if you want it

[Python-ideas] Re: New feature

2020-10-16 Thread Chris Angelico
On Fri, Oct 16, 2020 at 8:21 PM Rob Cliffe via Python-ideas wrote: > > > > On 13/10/2020 23:35, Guido van Rossum wrote: > > Can one of the educators on the list explain why this is such a > > commonly required feature? I literally never feel the need to clear my > > screen -- but I've seen this

[Python-ideas] Re: except-try block

2020-10-16 Thread Rob Cliffe via Python-ideas
On 16/10/2020 07:55, Steven D'Aprano wrote: Hmmm, well, I won't categorically say you *must* use a function, but I will say that using a function is probably the best solution. If you nest your function inside the major function, you don't even need to pass arguments: def function(a,

[Python-ideas] Re: Weakrefs for lru_cache?

2020-10-16 Thread Serhiy Storchaka
15.10.20 20:49, Ram Rachum пише: > Hi everyone, > > For many years, I've used a `cache` decorator that I built > > for caching Python functions. Then `functools.lru_cache` was > implemented, which is

[Python-ideas] Re: Weakrefs for lru_cache?

2020-10-16 Thread Ram Rachum
Well, I can also write a decorator that does lru_cache, but there are a lot of advantages that it's available in the standard library... On Fri, Oct 16, 2020 at 12:35 PM Antoine Pitrou wrote: > On Fri, 16 Oct 2020 11:34:08 +0300 > Ram Rachum wrote: > > Did you mean like keeping a hidden

[Python-ideas] Re: Weakrefs for lru_cache?

2020-10-16 Thread Antoine Pitrou
On Fri, 16 Oct 2020 11:34:08 +0300 Ram Rachum wrote: > Did you mean like keeping a hidden attribute on the object with the result? > Well, that'd require manually keeping track of these attributes for each > method I'm caching. I do that sometimes, but it's verbose. You can write a decorator

[Python-ideas] Re: Weakrefs for lru_cache?

2020-10-16 Thread Antoine Pitrou
On Thu, 15 Oct 2020 22:31:25 -0600 Carl Meyer wrote: > On Thu, Oct 15, 2020 at 3:33 PM David Mertz wrote: > > So the use case needs to be: > > > > * Function operates on large objects > > * Function operates on large, immutable objects > > * Function never takes literal or computed arguments

[Python-ideas] Re: New feature

2020-10-16 Thread Rob Cliffe via Python-ideas
On 13/10/2020 23:35, Guido van Rossum wrote: Can one of the educators on the list explain why this is such a commonly required feature? I literally never feel the need to clear my screen -- but I've seen this requested quite a few times in various forms, often as a bug report "IDLE does not

[Python-ideas] Re: Weakrefs for lru_cache?

2020-10-16 Thread Irit Katriel via Python-ideas
When you initially opened this thread I thought you were suggesting a decorator that does the equivalent of a WeakValueDictionary. I guess you would need both in the library.  We have both types of weak caches in our system (weak on value or weak on key), which we implemented. But the one that

[Python-ideas] Re: Weakrefs for lru_cache?

2020-10-16 Thread Ram Rachum
I do that in a part of my code, and I need to handle the logic of first looking at that dictionary, and if it's not there, calculate it and store it in the dictionary. Is this what you meant? That's what I'm trying to avoid, doing all that manual work that a cache decorator is supposed to do for

[Python-ideas] Re: Weakrefs for lru_cache?

2020-10-16 Thread Irit Katriel via Python-ideas
You can use a global WeakKeyDictionary keyed by the object to achieve the same without having anything on the object. On Friday, October 16, 2020, 09:37:05 AM GMT+1, Ram Rachum wrote: Did you mean like keeping a hidden attribute on the object with the result? Well, that'd require

[Python-ideas] Re: Weakrefs for lru_cache?

2020-10-16 Thread Ram Rachum
Did you mean like keeping a hidden attribute on the object with the result? Well, that'd require manually keeping track of these attributes for each method I'm caching. I do that sometimes, but it's verbose. On Fri, Oct 16, 2020 at 11:26 AM Paul Moore wrote: > On Fri, 16 Oct 2020 at 08:42, Ram

[Python-ideas] Re: Weakrefs for lru_cache?

2020-10-16 Thread Paul Moore
On Fri, 16 Oct 2020 at 08:42, Ram Rachum wrote: > > That's similar to my use case. Big mutable object (right now a state in a > multi-agent simulation) with lots of methods that I want to cache. Thanks all for the explanation of use cases. In this specific example, if you're caching methods

[Python-ideas] Re: Weakrefs for lru_cache?

2020-10-16 Thread Ram Rachum
That's similar to my use case. Big mutable object (right now a state in a multi-agent simulation) with lots of methods that I want to cache. "Given that it's not really hard to write your own caching decorator, I don't feel like this needs to change the API of lru_cache." Well, given that it's

[Python-ideas] Re: except-try block

2020-10-16 Thread Steven D'Aprano
On Fri, Oct 16, 2020 at 02:14:27AM +0100, Rob Cliffe via Python-ideas wrote: > >You mean like a goto statement? I'm not sure what a "pseudo-loop" > >is, other than a way to use break as goto. > > > >ChrisA > > Is that bad?  As I tried to explain, sometimes a process may need to be >

[Python-ideas] Re: except-try block

2020-10-16 Thread Chris Angelico
On Fri, Oct 16, 2020 at 4:37 PM Rob Cliffe via Python-ideas wrote: > Sorry, but I get the impression from your comment (comparing it to goto) > that you think breaking out of a ... let's call it a once-only loop ... > is a Bad Thing and to be discouraged. If I've misunderstood, I > apologise and