7 ms·
I hate to be a naysayer, but if you really want something like this -- just use ipython. You can put any python you want in a file and run $ipython -i main.py
by kjeetgill 4y ago
I hate to be a naysayer, but if you really want something like this -- just use ipython.
You can put any python you want in a file and run $ipython -i main.py and it'll drop you in a shell with whatever you want in scope. It can load configs from your ~/config directory, have a command line history, use tab completion, and you can the full language to compose those operations and inspect your results.
- Aperocky 4y ago> you can the full language to compose those operations and inspect your results. The purpose is not to do this however, the goal for a repl cli is usually to invoke a set of particular, already implemented commands, not on the fly python input and output. The implementation will be predefined and packaged, repl are only used to run a list of specific commands with arguments that implementation has already defined. The purpose of such a repl is usually for context heavy operations where you don't want to instantiate all the context each time you call or be doing IPC calls. This is a simple way to keep a single process running and having a repl cli to communicate with it. The repl itself is not for composing code, but for executing commands. Think of something like the command line shell to query a nosql db or a list of command to interact with a particular system.
- doix 4y ago> The purpose is not to do this however, the goal for a repl cli is usually to invoke a set of particular, already implemented commands, not on the fly python input and output. The implementation will be predefined and packaged, repl are only used to run a list of specific commands with arguments that implementation has already defined. That's a very strange definition for a REPL, I would just call that an (interactive) CLI. Maybe that's why you couldn't find anything when you were doing your search? I used python-prompt-toolkit [0] when building such interfaces. pgcli [1] is an example of such an interface built with prompt-toolkit. It has a lot of nice autocomplete and readline emulation options. Maybe it's something you can integrate with your project. [0] https://github.com/prompt-toolkit/python-prompt-toolkit https://github.com/prompt-toolkit/python-prompt-toolkit [1] https://www.pgcli.com/ https://www.pgcli.com/
- nurettin 4y agoLooks like it supports inputs with syntax highlighting. This is something I've been looking for. Thanks for mentioning ppt. https://python-prompt-toolkit.readthedocs.io/en/master/pages/asking_for_input.html#syntax-highlighting https://python-prompt-toolkit.readthedocs.io/en/master/pages...
- Aperocky 4y agoAh this makes a lot of sense, I see my lack of naming skills cuts both ways. It does seem the project you linked do refer themselves as repl in some capacity and is much more than what I had in mind, but these are great references.