Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyTerminal .process(code) utility #2026

Merged
merged 2 commits into from
Apr 12, 2024

Conversation

WebReflection
Copy link
Contributor

Description

This MR allows PyTerminal users to actually process imperatively some code which is something overly cumbersome otherwise within both interpreters, as these are orchestrated in a worker and not so easy to reach as both are constantly blocked due readline holding them on main.

Changes

  • expose an utility to process(code) where each line is simulated as pasted on the terminal
  • verify everything works as expected

Checklist

  • All tests pass locally
  • I have updated CHANGELOG.md
  • I have created documentation for this(if applicable)

@JeffersGlass
Copy link
Member

Do you have a small code sample of how this feature would be used? I think I understand, but I want to be sure.

@WebReflection
Copy link
Contributor Author

WebReflection commented Apr 11, 2024

@JeffersGlass visit this page: https://webreflection.github.io/coincident/test/pyterminal/

find some python code (multiline) in your editor ... try to copy and paste, see it failing. Now click the tiny top right button and paste that very same code into the prompt then see it working, as in: it's processed correctly and you can just, eventually add, an extra Enter and see the result.

That live page uses already the latest npm version of pyscript built from this MR.

P.S. I was planning to demo this in today PyScript Fun call, if you'll be there I'll explain it all.

@ntoll
Copy link
Member

ntoll commented Apr 12, 2024

OK... so we should also update the docs before releasing this (for the benefit of those asking for this feature). Also, the demo to which you link... the icon on the top right, in latest Firefox on Mac I see a missing unicode character glyph (see attached screenie):

Screenshot 2024-04-12 at 10 54 35

@WebReflection
Copy link
Contributor Author

WebReflection commented Apr 12, 2024

@ntoll the demo is out of this repository or project scope, it's an external playground ... I can change that icon but by no mean that page should block this MR (it might disappear too at some point)

The documentation should land in the right repo too 😉

@WebReflection
Copy link
Contributor Author

@ntoll is the icon any better now? https://webreflection.github.io/coincident/test/pyterminal/

@WebReflection
Copy link
Contributor Author

@ntoll btw, if we want to trust that page to exist (for docs or anything else) I'd rather move it into PSDC or inside our examples ... it would make more sense than relying on something I've just trashed in coincident only because it has mini-coi already up and running, imho ... still, this is unrelated to this MR, it was just a smoke test quick and easy, also not using our latest release (as it doesn't exist yet).

@ntoll
Copy link
Member

ntoll commented Apr 12, 2024

Agreed WRT docs. We should put the demo in the demos. :-)

@WebReflection
Copy link
Contributor Author

@ntoll so can we move this forward? it's blocking eventually the next up for links in terminal

@ntoll
Copy link
Member

ntoll commented Apr 12, 2024

Apologies... yes.

@WebReflection WebReflection merged commit 44cd627 into pyscript:main Apr 12, 2024
2 checks passed
WebReflection added a commit to WebReflection/pyscript that referenced this pull request Apr 12, 2024
* PyTerminal .process(code) utility

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants