Content-Length: 257666 | pFad | https://github.com/adafruit/circuitpython/pull/8344

D6 add support for "repl.py" by jepler · Pull Request #8344 · adafruit/circuitpython · GitHub
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

add support for "repl.py" #8344

Merged
merged 2 commits into from
Aug 29, 2023
Merged

add support for "repl.py" #8344

merged 2 commits into from
Aug 29, 2023

Conversation

jepler
Copy link

@jepler jepler commented Aug 28, 2023

This file, if it exists and safe mode is not active, is executed before showing the REPL prompt.

You can use this file to do whatever you like, but often it is helpful to set up imports or functions that will be used in an interactive session:

from board import *
from some_sensor import SomeSensor
...

You will be notified that repl.py is being used by the line "repl.py output:".

In safe mode the file is not used.

If the file encounters an exception, the exception is printed and then the REPL prompt is shown:


repl.py output:
loaded repl.py
Traceback (most recent call last):
  File "repl.py", line 8, in <module>
ZeroDivisionError: division by zero

Adafruit CircuitPython [version info snipped]
>>>

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Thanks for the quick impl and doc update.

Copy link

@bill88t bill88t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Such a simple and neat feature!

Some more applications for it:

  • Have a permanently running app and use REPL as a debugging mode of sorts, where everything is loaded automatically.
  • Have a help message (regarding your functions) shown upon entering the repl, clearing the screen or even displaying a new ansi title.
  • Show useful board stats upon entering the repl like the temperature or the board ip.
    (I know the statusbar is supposed to do that but eh)

@tannewt tannewt merged commit b81c0e2 into adafruit:main Aug 29, 2023
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.

3 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/adafruit/circuitpython/pull/8344

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy