AREPL: vscode edition
AREPL automatically evaluates python code in real-time as you type
AREPL is availible for free on the vscode marketplace
First, make sure you have python 3 installed.
Open a python file and right click on the editor title for AREPL launch options.
Or run AREPL through the command search:
or use the shortcuts:
control-shift-a (current doc) /
control-shift-q (new doc)
Real-time evaluation: no need to run - AREPL evaluates your code automatically. You can control this (or even turn it off) in the settings
Variable display: The final state of your local variables are displayed in a collapsible JSON format
Error display: The instant you make a mistake an error with stack trace is shown
Settings: AREPL offers many settings to fit your user experience. Customize the look and feel, debounce time, python options, and more!
If you want to dump local variables or dump variables at a specific point in your program you can use the dump function:
from arepl_dump import dump
kilometers = miles*1.60934
dump() # dumps all the vars in your function
# or dump when function is called for a second time
for char in ['a','b','c']:
dump(char,2) # dump a var at a specific iteration
dump(a) # dump specific vars at any point in your program
You can use howdoi with arepl.
First install in the terminal / command line:
pip install howdoi
Then reopen arepl and you will be able to use howdoi to get answers to your questions. For example:
howdoi('calculate fibbonaci in python')
will give you a function to calcualate a fibonaci number
If you want to avoid a section of code being executed in real-time (due to it being slow or calling external resources) you can use #$save. For example:
i = 2
while i * i <= n:
if n % i:
i += 1
n //= i
# this takes a looonnggg time to execute
result = largest_prime_factor(8008514751439999)
print("but now that i saved i am back to real-time execution")
x = random.random()
print(x) # this number will not change when editing below the #$save line
Please note that #$save does not work with certain types, like generators. If #$save fails in pickling the code state file an issue so I can look into it.
Alternatively, you can use the areplStore variable to store data in between runs.
#$end comment to indicate the end of the real-time code. Code after
#$end will not be executed in real-time.
This is useful if you have something specific you want to run without running the entire file along with it. For example:
x = calculate_all_digits_of_pi()
# I can inspect variables without rerunning calculate_all_digits_of_pi
# the shortcut is control-enter - the code block should flash yellow.
print(x) # 3.14......
# I can also temporarily change the state of variables
# note that control-enter will run all adjacent lines of code
x = math.floor(x)
print(x) # 3
# i only want to do this once I've determined that x is correct
Note that you can also use control-enter to run a block of code outside
I have overridden the display of some types (like datetime) to be more readable to humans.
If you want a type to be displayed in a particular manner just file an issue
Check out the wiki!
Contributing to the project
See the wiki page on getting started. Contributions welcome!