[Python-ideas] REPL preview / throwOnSideEffect / Sandboxing

2020-12-22 Thread Jun Wu
Context: I was thinking about having embedding Python in a REPL with live preview of evaluation result of pure functions. Similar to nodejs REPL or Chrome DevTools (which uses {throwOnSideEffect: true} under the hood). This is somewhat similar to sandboxing. I'm aware of tricks like `object.__s

[Python-ideas] Re: built in to clear terminal

2020-12-22 Thread David Mertz
As I say, I just discovered the fact about conda vendoring `clear`. I haven't looked further into what includes it as dependency... although it seems to be in pretty much all my environments, so maybe IPython? On Wed, Dec 23, 2020 at 12:46 AM Christopher Barker wrote: > On Tue, Dec 22, 2020 at

[Python-ideas] Re: built in to clear terminal

2020-12-22 Thread Eryk Sun
On 12/22/20, David Mertz wrote: > On Tue, Dec 22, 2020 at 10:26 PM Chris Angelico wrote: > > I'm not sure about Windows. Is 'cls' built into the command-line executable > itself (like Busybox) or is it an exe? CLS is an internal command of the CMD shell. An internal command takes precedence as l

[Python-ideas] Re: built in to clear terminal

2020-12-22 Thread Christopher Barker
On Tue, Dec 22, 2020 at 2:58 PM David Mertz wrote: > Somewhat supporting my concern, I just was surprised to find this: > > % ll `which clear` > -rwxrwxr-x 2 dmertz 14344 Nov 14 17:07 /home/dmertz/miniconda3/bin/clear > % ll /usr/bin/clear > -rwxr-xr-x 1 root 14656 Feb 29 2020 /usr/bin/clear >

[Python-ideas] Re: built in to clear terminal

2020-12-22 Thread David Mertz
On Tue, Dec 22, 2020 at 10:26 PM Chris Angelico wrote: > A tight loop clearing the screen? If you have that, you have much > bigger problems :). But shelling out to clear/cls has another problem: > it's a big ol' > dependency. You need to have the corresponding command, and it needs > to be acces

[Python-ideas] Re: built in to clear terminal

2020-12-22 Thread Chris Angelico
On Wed, Dec 23, 2020 at 9:15 AM Steven D'Aprano wrote: > > On Mon, Dec 21, 2020 at 08:22:35AM +1100, Cameron Simpson wrote: > > >is it so bad to use a subprocess? > > > > Yes. It is _really slow_, depends on external reaources which might not > > be there, and subprocess brings other burdens too.

[Python-ideas] Re: built in to clear terminal

2020-12-22 Thread Steven D'Aprano
On Mon, Dec 21, 2020 at 08:22:35AM +1100, Cameron Simpson wrote: > Anyway, I think it should be in curses (or be loaded via curses on > demand), and just have a clear_screen function thus: > > def clear_screen(): > setupterm() > print(ti_getstr('cl'), end='', flush=True) [..

[Python-ideas] Re: built in to clear terminal

2020-12-22 Thread Steven D'Aprano
On Sat, Dec 19, 2020 at 08:50:57PM -0800, Guido van Rossum wrote: > On Sat, Dec 19, 2020 at 7:43 PM Steven D'Aprano wrote: > > > Thread is here: > > > > > > https://mail.python.org/archives/list/python-ideas@python.org/message/EWQ2BOL3WVZAU2V2MT3HLXN3AEBHANNZ/ > > > > > > I don't think this needs

[Python-ideas] Re: A PEP to encourage people to mind docstrings in stub files

2020-12-22 Thread Steven D'Aprano
On Tue, Dec 22, 2020 at 08:07:25PM +0300, Alexey Volobuev wrote: > Hi! > > Sometimes you have to put docstrings in stub files e.g. when using code > generation. In that case, stubs are the only place you can locate "objects" > to add docstrings to. > > Thus it is frustrating to find that docstrin

[Python-ideas] Re: Standalone bool?

2020-12-22 Thread Steven D'Aprano
On Tue, Dec 22, 2020 at 08:28:30AM +1100, Steven D'Aprano wrote: > An alternative, which may be better or worse but is probably worth > considering, is to create your own wrapper proxy for True and False, > then use that. It has come to my attention that my post may have been unclear. I don't

[Python-ideas] Re: A PEP to encourage people to mind docstrings in stub files

2020-12-22 Thread Jonathan Fine
Hi Alexey You wrote that docstring-related software generally fails to handle docstrings properly in stub files. I don't have experience of this, probably because I don't use such software. Please would you provide some examples. Ideal would be issued that have been raised (by you if need be) for

[Python-ideas] A PEP to encourage people to mind docstrings in stub files

2020-12-22 Thread Alexey Volobuev
Hi! Sometimes you have to put docstrings in stub files e.g. when using code generation. In that case, stubs are the only place you can locate "objects" to add docstrings to. Thus it is frustrating to find that docstring-related software generally tends to ignore the presence of docstrings in stub

[Python-ideas] Re: Standalone bool?

2020-12-22 Thread Eric V. Smith
On 12/22/2020 9:04 AM, Jeff Allen wrote: On 22/12/2020 00:52, Christopher Barker wrote: On Mon, Dec 21, 2020 at 3:37 PM Greg Ewing mailto:greg.ew...@canterbury.ac.nz>> wrote: > However, that ship has sailed. I think it would have been minimally > disruptive when True and False were

[Python-ideas] Capture manylinux environment set-up in pyproject.toml

2020-12-22 Thread christopher . antonellis
The manylinux project does not specify a way to record "environment set up" information required to build wheels from certain packages. Some packages require that the stock manylinux environment be modified by installing system dependencies, setting environment variables, modifying the filesyst

[Python-ideas] Re: built in to clear terminal

2020-12-22 Thread Stephen J. Turnbull
Eryk Sun writes: > Here are some concerns I have: This is the best argument for a clear_terminal (clear_window?) builtin I've seen. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org h

[Python-ideas] Re: Standalone bool?

2020-12-22 Thread Jeff Allen
On 22/12/2020 00:52, Christopher Barker wrote: On Mon, Dec 21, 2020 at 3:37 PM Greg Ewing mailto:greg.ew...@canterbury.ac.nz>> wrote: > However, that ship has sailed. I think it would have been minimally > disruptive when True and False were first introduced, It would have been jus

[Python-ideas] Re: built in to clear terminal

2020-12-22 Thread Eryk Sun
On 12/22/20, Barry Scott wrote: > > import sys > > def clear_terminal(): > if sys.platform == 'win32': > import ctypes > kernel32 = ctypes.windll.kernel32 > # turn on the console ANSI colour handling > kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7) > >

[Python-ideas] Add something to `yield from` to allow delegating to an already started generator

2020-12-22 Thread Paolo Lammens
Currently, there is no way to correctly delegate to a partially consumed generator with `yield from` without re-implementing the entire semantics of `yield from` in user code. (In particular, I'm referring to full-fledged bidirectional generators that make use of .send(), .throw(), and .close().

[Python-ideas] Re: built in to clear terminal

2020-12-22 Thread Barry Scott
> On 22 Dec 2020, at 09:49, Barry Scott wrote: > > The simplest answer is > > print('`\x1b[2J\x1b[H') > > Are there any terminals that this does not work on that are in active use? > > Is using curses that uses termcap needed these days? > > Of course Windows is the outlier, but the

[Python-ideas] Re: Possibility to decorate single code line or code block?

2020-12-22 Thread Paul Sokolovsky
Hello, On Mon, 21 Dec 2020 12:43:39 -0800 Christopher Barker wrote: > Jonathan, did you notice: > > python3 -m imphook -i mod_stmt_deco -m example_stmt_deco > > I suspect mod_stmt_deco is some code that Paul wrote. > > Guessing now, you can implement with with an import_hook, and I'm also > g

[Python-ideas] Re: built in to clear terminal

2020-12-22 Thread Barry Scott
The simplest answer is print('`\x1b[2J\x1b[H') Are there any terminals that this does not work on that are in active use? Is using curses that uses termcap needed these days? Of course Windows is the outlier, but the new Windows Terminal supports ANSI escapes sequences and utf-8. I tes

[Python-ideas] Re: What if exec() took a module object directly?

2020-12-22 Thread Paul Sokolovsky
Hello, On Tue, 22 Dec 2020 18:27:01 +1100 Steven D'Aprano wrote: > On Mon, Dec 21, 2020 at 04:36:21PM +0300, Paul Sokolovsky wrote: > > Hello, > > > > I posted on python-dev a question regarding builtin vars() > > vs .__dict__ attribute dichotomy: > > https://mail.python.org/archives/list/pytho

[Python-ideas] Re: Standalone bool?

2020-12-22 Thread Serhiy Storchaka
22.12.20 03:18, David Mertz пише: > Indeed.  The discussion around this was quite specifically that many > people defined: > > True = 1 > False = 0 > > At the top of their code, and used that.  This was the main reason they > were built-ins rather than keywords, so as not to break that large body

[Python-ideas] Re: Standalone bool?

2020-12-22 Thread Serhiy Storchaka
21.12.20 10:11, Paul Bryan пише: > Wouldn't that still work if bool's __int__ returns 1? Implementing `__index__` would solve 90% of all problems with non-int booleans. But not the example provided by David (it requires `__add__`). And there may be more specific cases when you need to make arithme

[Python-ideas] Re: Standalone bool?

2020-12-22 Thread Serhiy Storchaka
21.12.20 10:09, David Mertz пише: > I sure hope this never happens! It would break millions of working lines > and kill a common useful pattern. > > ntrue = sum(this == that for this, that in items) It is too, but the main reason is that the C code parses boolean parameters as integers (using PyA

[Python-ideas] Re: Standalone bool?

2020-12-22 Thread Serhiy Storchaka
22.12.20 02:52, Christopher Barker пише: > On Mon, Dec 21, 2020 at 3:37 PM Greg Ewing > wrote: > > However, that ship has sailed. I think it would have been minimally > > disruptive when True and False were first introduced, > > It would have been j