ptpython | A better Python REPL | Code Editor library
kandi X-RAY | ptpython Summary
kandi X-RAY | ptpython Summary
A better Python REPL
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Configures the function
- Set a code color scheme
- Generate style
- Generate a new style
- Create key bindings
- Create a new Document with the given cursor position
- Select other window
- Update the default buffer
- Create a REPL instance
- Read text from the UI
- Get all completions for the given document
- Get the bottom toolbar fragment
- Create a completer instance
- Get the compiler flags
- Start the REPL
- Return the grammar for the path completions
- Load startup files
- Create an interactive shell
- Create a lexer
- Get the completions for the given document
- Create a sidebar for the given python input
- Create a status bar
- Create an Application
- Run the program
- Invoked when the input timeout occurs
- Read from the REPL
- Validate text
ptpython Key Features
ptpython Examples and Code Snippets
$ parsel --help
Usage: parsel [OPTIONS] [URL]
Interactive shell for css and xpath selectors
Options:
-h TEXT request h
$ rake shell
$ rake shell[bpython]
$ rake shell[ipython]
Notice that this is the prompt_toolkit 3.0 documentation. It is mostly
compatible with the 2.0 branch. The difference is that prompt_toolkit 3.0
requires at least Python 3.6. On the plus side, it uses asyncio natively
(rather than it's own event loop
"""
Configuration example for ``ptpython``.
Copy this file to $XDG_CONFIG_HOME/ptpython/config.py
On Linux, this is: ~/.config/ptpython/config.py
"""
from prompt_toolkit.filters import ViInsertMode
from prompt_toolkit.key_binding.key_processor impor
#!/usr/bin/env python
"""
Serve a ptpython console using both telnet and ssh.
Thanks to Vincent Michel for this!
https://gist.github.com/vxgmichel/7685685b3e5ead04ada4a3ba75a48eef
"""
import asyncio
import pathlib
import asyncssh
from prompt_toolk
#!/usr/bin/env python
"""
Example of running the Python REPL through an SSH connection in an asyncio process.
This requires Python 3, asyncio and asyncssh.
Run this example and then SSH to localhost, port 8222.
"""
import asyncio
import logging
imp
def send_text(self, txt):
# this should write to the 'stdin' pipe,
# thus provoking input reading from Pdb
print("WRITING TO PDB's STDIN")
self.w.write(txt.decode())
self.w.flush()
@echo off call "%~dp0env_for_icons.bat" cd/D "%WINPYWORKDIR%" rem backward compatibility for python.exe "%WINPYDIR%\python.exe" %*
Community Discussions
Trending Discussions on ptpython
QUESTION
I am writing a web shell, using ptpython, gevent and Flask on the server side and xtermjs and websockets on the client side.
I would like the normal breakpoint()
function of Python to work, using pdb
.
I was happy to find out Pdb
class takes custom stdin
and stdout
, however I cannot manage to get the thing working :(
In the web shell, what user types goes to the server process via a websocket: there is a listening greenlet, that writes to a pipe that is read by ptpython. Then, ptpython output is sent via the websocket. So far so good, it works beautifully.
Now with pdb
: thanks to sys.breakpointhook
I create a custom Pdb
instance with stdin being a pipe and stdout another pipe. I carefully use gevent.fileobject.FileObjectPosix
to have non-blocking, cooperative I/O streams. I take care of having user input writing to the
input pipe and I expect output to the other pipe, so I can redirect it to the appropriate "standard output" handling routine in my code.
But, after having received the first messages corresponding to pdb
prompt, I am stuck everything seems to be blocked.
I reproduce the behaviour I have with the following code, any help would be appreciated:
...ANSWER
Answered 2021-May-13 at 20:44You must flush your write (in addition to monkey patching):
QUESTION
I've been trying to figure out how to get save and read in the history of my python commands in a ptpython
console, but haven't been able to do so. All of my efforts have so far been variations of this answer. However, I still am not able to read in my history.
I would simply like to be able to press the "up" and "down" arrows to go through my python commands from a previous console session (not the current console session that I'm in). Here's what I currently have in my $PYTHONSTARTUP
file:
ANSWER
Answered 2020-Jan-27 at 18:38If you check source code for embed then you see option history_filename=
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ptpython
You can use ptpython like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page