Comments (10)
[ LP comment 1 by: anatoly techtonik, on 2009-06-04 12:33:54.822394+00:00 ]
from ipython.
I'd like to ask about the interaction between IPython console run in Windows command prompt and sys.std* objects. I would think there would be no interaction, because IPython console uses other means implementing iteractive io to provide features as colors and autocompletition. However for example setting sys.stdout = 3 produces infinite stream of errors.
There is a long standing issue with Unicode charcters in Python interactive console being run on Windows (http://bugs.python.org/issue1602). I'm trying to workaround by using custom stream objects, but there is some weird interaction witch IPython interactive console, see Drekin/win-unicode-console#2.
from ipython.
I would certainly expect setting sys.stdout
to an integer to break things spectacularly.
From IPython's point of view, we use sys.stdout as normal, i.e. using print() (and possibly sys.stdout.write() in some places). As you've already noticed, pyreadline does things with it.
from ipython.
So things like printing colorful In[] and Out[] are done by calling some pyreadline api? But pyreadline talks to Windows console directly, so sys.std* objects are bypassed, so I don't get how their changing could affect displaying colorful propmt.
from ipython.
We write to stdout ANSI control codes for changing colours etc., which are recognised by terminal emulators on *nix systems. On Windows, pyreadline intercepts those codes with a custom sys.stdout object, and calls the appropriate Windows console functions. So if you replace sys.stdout back to sommething like the default, you probably see the effects of sending those ANSI control sequences directly to the Windows terminal.
from ipython.
That makes sense, but why can't I see the wrapper object? sys.stdout in IPython console is standard output stream and sending ANSI control sequences doesn't work with it.
from ipython.
Strange, I'm not sure about that, and I don't have my Windows VM handy to investigate.
I've just looked at our prompts code - we do just generate a string with ANSI control sequences, and pass that to input()
.
from ipython.
Actually, passing the ANSI sequence to input()
works. The input
function doesn't use sys.stdout
for prompt when readline
is available, but when sys.stdout
is chaged, it uses the changed variant. So it's again fault of complicated interaction between readline
and Python core. See http://bugs.python.org/issue17620.
from ipython.
It sounds like we should close this one and leave the Python 17620 issue you reference above for the follow-up, right?
from ipython.
With all the recent prompt_toolkit refactor I'm going to close this one which is likely not relevant anymore after 7 years. Thanks all, please reopen a new issue if needed.
from ipython.
Related Issues (20)
- Create a `_process_emscripten.py` HOT 2
- Add a `display_mermaid(diagram: str) function which rendered the provided diagram as a Mermaid diagram HOT 19
- The `metadata` link points to [`importlib.metadata`](https://docs.python.org/3/library/importlib.metadata.html#metadata) which is a totally different thing right? (or am I just very confused!?)
- How to control possibly new display options controlling file abbrevations HOT 2
- Magic does not work well with ```ast_transformers```/```inspect``` HOT 1
- Multiple calls to matplotlib.pyplot.switch_backend HOT 1
- Default ipython_warning_is_error to False to match Sphinx's behavior HOT 1
- Allow parsing black-compatible IPython codeblock
- IPython directive can segfault in sphinx parallel build HOT 1
- Feature Request : Autocomplete and docstring working when instantiating using class directly HOT 3
- IPython.lib.pretty.for_type does not seem to work for float (but does for int) HOT 1
- Github action workflows do not pass even on main branch HOT 3
- More complete mime hook API for inspector? HOT 1
- `sys.monitoring` and an "always live" debugger HOT 1
- pygments for coloring source, not just REPL HOT 3
- New tutorial section: debugging with IPython HOT 4
- magic conda fails in windows (re can not parse path) HOT 2
- IPython 8.22 should require traitlets 5.13 HOT 1
- AssertionError Traceback in google collab
- Word-based backward deletion? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ipython.