[Python-ideas] A better interactive prompt

Nathaniel Smith njs at pobox.com
Wed Oct 26 18:24:47 EDT 2016


On Wed, Oct 26, 2016 at 3:16 PM, Cody Piersall <cody.piersall at gmail.com> wrote:
> On Wed, Oct 26, 2016 at 4:48 PM, Paul Moore <p.f.moore at gmail.com> wrote:
>> Good point. We could, of course, detect when stdin is non-interactive,
>> but at that point the code is starting to get unreasonably complex, as
>> well as having way too many special cases. So I agree, that probably
>> kills the proposal.
>
> Isn't that check really just an isatty() check?  Or is that not
> reliable enough for some reason?  Here's some code that performs that
> check, and works on Linux and Windows:

It might or might not be an isatty() check (it's actually a bit more
complicated, there's -i and various other things to take into
account), but it hardly matters -- Python already has well-defined
logic for deciding whether it should launch an interactive REPL or
not. If we were going to do this, we'd keep that logic in place while
swapping out the actual start_a_REPL() call with something else. There
might be showstoppers here but I don't think this is one of them :-)

-n

-- 
Nathaniel J. Smith -- https://vorpus.org


More information about the Python-ideas mailing list