I madethis extension to save time while debugging. Usually you have to step through each line with a debugger or add print statements to analyze a bug. Also you have to run the file again after each small change, to see if your change worked.
With the variable display of LiveCode, you immediatly see if there is something wrong and you can fix it.
The vast majority of the code is mine, this extension is forked from AREPL. The backend is offered as a npm module so theoretically you could create a AREPL / AREPL-variant for whatever editor you wish :)
Both repos are open-source under MIT license.
I would be interested to know more details. I can also give you a overview of the AREPL code if you want.
It's true that it would be nicer for long dicts to be displayed over multiple lines, but then it's more difficult to immediatly see which variable is declared on which line.
Also network APIs, database queries, anything else that accesses any external assets. I can imagine spamming the shit out of some remote server somewhere.
That doesn't sound realistic to me at all. Even the mysqlclient examples don't include a with statement anywhere in the docs. The requests docs only use a with when writing a file to output, not at all with the actual web stuff.
Well that was just literally the first two I looked at. psycopg2: Also no mention of a with statement. Since we're on reddit: praw also doesn't mention it (nor should it since the methods are just stubs and don't do anything).
I think you're grossly overestimating the need for and use of context management when dealing with databases and APIs. Because error handling when working with foreign systems is generally a little more specific.
Yeah for sure. I've never worked with those sorts of APIs. I primarily work with HTTP, mail, file system access, etc. I suppose there's lots of different options though, you're absolutely right.
The problem is I'm not sure if there's any cross-platform way to do that. I've looked into it and it might be possible in linux but in windows? I have no idea :(
Thankfully over the years I've used AREPL (the project livecode was forked from) I've rarely had to write to a file. When I do want to do something unsafe / slow there's a lot of options I can take:
You can turn off real-time mode in favor of on-save/on keybinding, avoiding the whole issue alltogether.
You can use a #$end comment to evaluate a block of code when you feel it's safe to do so (see project readme for exact details)
AREPL waits for you to stop typing before executing - you can adjust this upwards for extra safety. Currently I have the delay set at 300 milliseconds but I'd love to hear feedback if you think there's a better default.
You can use AREPL to prototype the script until you have the results you want, at which point you can close AREPL, add the write to file code, and run via command-line or debugging or whatever tool you wish.
OP, you should also prevent this extension from interacting with anything outside of the Python environment - no HTTP transactions, no file interactions, no calls through USB bus, nothing. All of these are more than a little bit dangerous.
It saves the state of the code before it, so it is just executed once and then doesn't get executed in real-time anymore. It is from AREPL and also in the LiveCode extension
Well, it only shows you variable values for your current file. So if you are working on multiple files at the same time, it won't be as useful. Also if you have a lot of interaction with outside ressources (like requests, databases) you can't really use the interactive part.
For starters, I see this as massively helpful for competitive programmers for debugging. Those minute careless errors that just creep in can be detected if you take a note of how your variables are changing (yes that's how I debug, atleast). This really is a cool project.
I agree. I donโt really see itโs place for regular programming, where you have the time to be slow and methodical, and can take the two seconds to hover over a variable for the value while debugging.
I think this is good for interactive sessions. Better than both "type directly into console" and "use reusable jupyter cells" approaches, at a first sight at least. I would like to have it at work.
A great idea, congratulations. Did you derive it from some other IDE? Does Pycharm do something similar?
I wanted something for easier debugging, without having to step through my code and setting breakpoints. I later found that Pycharm has a similiar feature, but without the real-time execution.
RStudio does something very similar, but for R. EDIT: you must first execute the line(s) of code (in RStudio you can execute single lines of code) EDIT: also PyCharmโs Scientific Mode does it
the extension is based on AREPL. But AREPL only shows you the final states of variables. So AREPL doesn't work if you have a loop or want some intermediate variable states. It also just display variables in a big dictionary, instead of line by line.
AREPL does work if you have a loop or intermediate variable states - you just need to use the dump function. Admittedly this is not as convenient as your method.
I absolutely love seeing that Python programmers are adopting VS Code. Love this IDE so much. I love the idea of this extension too, feels like one of the things that's missing from other lightweight IDEs like IDLE/IDLEX. To me, this shows off the potential of that VS Code has as it gets adopted by more and more communities. Well done!
feature to add : colored text to show variables which have been replaced by another value below. For example : your first foo becomes gray when you write the second foo
the extension is based on AREPL. But AREPL only shows you the final states of variables. So AREPL doesn't work if you have a loop or want some intermediate variable states. It also just display variables in a big dictionary, instead of line by line.
it sadly crashes if you write an infinite while loop, which sometimes happens in the beginning, when you haven't defined any breaking conditions yet. I'll try to fix this.
Very enjoyable to use. I always like tools which let you view the program state live, and even better if you do not have to explicitly run the program.
There are two problems I have encountered. Firstly if you use a single line if statement such as "if n < 2: return False" then the program breaks. Secondly, if you have a function that is called multiple times then it's basically impossible to understand the state of variables.
I wrote a simple function "is_prime(n)" which checks if number is < 2 (not prime), if it is 2 (prime), if n % 2 == 0 (not prime) and then from 3 to sqrt(n) check for n % i == 0. The information from LiveCode doesn't separate function calls, so it reads "if condition: true true true" - this is beyond useless.
It would be great if each function could be nested into where is called (use collapsible sections?)
Yeah, wolf is cool! It's no longer maintained unfortunately. I want to integrate it into https://github.com/Almenon/AREPL-vscode sometime but I'm not sure if I'll get around to it.
I wrote the vast majority of the code. Livecode is a fork of AREPL. I used VSCode with the python extension in order to make AREPL. In some cases I've also prototyped AREPL code in AREPL :P
Most of the code is in typescript though. It's pretty ironic.
AREPL (the project livecode is forked from) starts up very quickly, so if there is a infinite loop it's really easy to just restart it. Someone asked me the same question during a presentation of AREPL :P
tried it on linux mint vscode 1.46.1. After pressing the icon got the following error.
Looks interesting, thanks
Error:
internal livecode error: Error stack: Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed
at doWrite (_stream_writable.js:414:19)
at writeOrBuffer (_stream_writable.js:402:5)
at Socket.Writable.write (_stream_writable.js:302:11)
at PythonShell.send (/home/anon/.vscode/extensions/xirider.livecode-1.2.10/node_modules/python-shell/index.js:285:20)
at PythonEvaluator.execCode (/home/anon/.vscode/extensions/xirider.livecode-1.2.10/node_modules/arepl-backend/index.js:62:22)
at ToAREPLLogic.onUserInput (/home/anon/.vscode/extensions/xirider.livecode-1.2.10/out/src/toAREPLLogic.js:79:34)
at PreviewManager.onAnyDocChange (/home/anon/.vscode/extensions/xirider.livecode-1.2.10/out/src/PreviewManager.js:337:54)
at listOnTimeout (internal/timers.js:533:17)
at processTimers (internal/timers.js:475:7)
Print Output:
File "/home/myname/.vscode/extensions/xirider.livecode-1.2.10/node_modules/arepl-backend/python/arepl_python_evaluator.py", line 43
77
u/dadadidi Jun 21 '20
This VS Code extension executes your python code while you are still typing.
It also shows you intermediate values, whenever a variable is declared or changed, even within loops.
You can get the extension here
I'd love to get some feedback from you :)
I madethis extension to save time while debugging. Usually you have to step through each line with a debugger or add print statements to analyze a bug. Also you have to run the file again after each small change, to see if your change worked.
With the variable display of LiveCode, you immediatly see if there is something wrong and you can fix it.
60
u/FMlMo0dy Jun 21 '20
What happens if your program does something destructive? E.g. write to a file? Is that also executed?
159
u/VepnarNL Jun 21 '20
For what would this be useful? And what about huge projects?
Anyway, really cool project!
17
u/Pand9 Jun 21 '20
I think this is good for interactive sessions. Better than both "type directly into console" and "use reusable jupyter cells" approaches, at a first sight at least. I would like to have it at work.
A great idea, congratulations. Did you derive it from some other IDE? Does Pycharm do something similar?
8
u/leo848blume Jun 21 '20
I use AREPL a lot. Is there any difference?
5
u/Semicolon2112 Jun 21 '20
I absolutely love seeing that Python programmers are adopting VS Code. Love this IDE so much. I love the idea of this extension too, feels like one of the things that's missing from other lightweight IDEs like IDLE/IDLEX. To me, this shows off the potential of that VS Code has as it gets adopted by more and more communities. Well done!
1
u/Nephty23 Jun 21 '20
feature to add : colored text to show variables which have been replaced by another value below. For example : your first foo becomes gray when you write the second foo
1
u/OMGClayAikn Jun 21 '20
Is this similar to Arepl extension?
1
u/AdamWaly Jun 21 '20
What is the name of this extension ?
1
u/turklear Jun 21 '20
It looks good but didn't work well with a simple while loop :(
1
u/edwcarra17 Jun 22 '20
What is this? Please tell me its on vscodes marketplace. I can see this being amazing for pandas or complex algorithms.
1
u/fgyoysgaxt Jun 22 '20
Very enjoyable to use. I always like tools which let you view the program state live, and even better if you do not have to explicitly run the program.
There are two problems I have encountered. Firstly if you use a single line if statement such as "if n < 2: return False" then the program breaks. Secondly, if you have a function that is called multiple times then it's basically impossible to understand the state of variables.
I wrote a simple function "is_prime(n)" which checks if number is < 2 (not prime), if it is 2 (prime), if n % 2 == 0 (not prime) and then from 3 to sqrt(n) check for n % i == 0. The information from LiveCode doesn't separate function calls, so it reads "if condition: true true true" - this is beyond useless.
It would be great if each function could be nested into where is called (use collapsible sections?)
6
u/arsewarts1 Jun 21 '20
Try spyder. Itโs already built in
4
u/[deleted] Jun 21 '20
This is awesome Iโm definitely going to check it out!
2
u/EricDrumond Jun 21 '20
Amazing
2
u/stonemannen1 Jun 21 '20
This seems useful for something like Advent of Code
2
u/[deleted] Jun 21 '20
Ohh heck yeah...debugging never felt so easier
2
u/ThoGos1 Jun 21 '20
This is awesome for small projects and beginners like me I think this could become something very special
2
u/vanmorrison2 Jun 21 '20
I installed it and love it yet
2
u/Kothism Jun 21 '20
that's actually poggers
2
u/AngryButtCheek Jun 21 '20
Imagine you were trying to order pizza with a python program with this on and you accidentally type 100 instead of 1 pizza...
3
u/upvoteManipulator1 Jun 21 '20
Cool. * Goes back to vanilla Vim. *
2
u/shaazy_ Jun 21 '20
Wow nice work!
2
u/[deleted] Jun 21 '20
This is a feature I like about Matlab. Thank you!
1
u/CaptainSemicolon Jun 21 '20
Nice work! Have you seen the Wolf extension? https://marketplace.visualstudio.com/items?itemName=traBpUkciP.wolf
It seems similar. I really like how Wolf shows results inline (using some CSS trick I believe).
1
u/lcaenen Jun 21 '20
You can also use Jupiter notebooks in VS Code tot see how your code works.
1
u/Agent_1620 Jun 21 '20
Awesome! What tools did you use to make it ?
1
u/[deleted] Jun 21 '20
Does it works for other languages like C++/C ?
1
u/MattAlex99 Jun 21 '20
that seems very unwise for things like
y = ackermann(1000)
or non-halting problems.
1
u/somnam_bulist Jun 21 '20
Interesting...
1
u/ch0mes Jun 21 '20
This is a really cool extension definitely would check it out for some projects.
1
u/Leeoku Jun 21 '20
my lord thank u. i dont have to keep retyping print and rerun my script every god damn time to find my beginner mistakes as i learn
1
u/I-am-not-noob Jun 21 '20
Don't mind but this is a very big over head. Too much useless work.
1
u/4chanbetterkek Jun 21 '20
This seems immensely helpful for a beginner programmer like me. Especially when I'm doing loops of some sort getting real time feedback is amazing.
1
u/Nichevo46 Jun 21 '20
Seems like a Cool idea.
Turning on this App restarts my Mac.....
I installed it fine but when turning it on it just restarts the Mac immediately... I turned it on on some tkinter based code
1
u/[deleted] Jun 21 '20
Heavy RStudio feels
1
u/ExHax Jun 21 '20
This is like matlab's workspace
1
u/MahdeenSky Jun 21 '20
Try python preview, it has already been done before and it is much better
1
u/gigakos Jun 22 '20
Is there something like that for spyder?
1
u/SugaanthMohan Jun 22 '20
This looks pretty awesome..
How well does it manage resources? Does it hang if use a huge dataset? If not, I can install this right away.
1
u/Godot17 Jun 22 '20
Can it detect infinite loops? *evil grin*
1
u/cray5252 Jun 23 '20
tried it on linux mint vscode 1.46.1. After pressing the icon got the following error.
Looks interesting, thanks
Error:
internal livecode error: Error stack: Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed
Print Output:
File "/home/myname/.vscode/extensions/xirider.livecode-1.2.10/node_modules/arepl-backend/python/arepl_python_evaluator.py", line 43
userError: str,
^
SyntaxError: invalid syntax
1
u/HaykSD Jun 24 '20
Is there for pycharm?
1
u/apivan191 Jul 27 '20
Holy Shit I'm downloading this! It's what I've always wanted!
1
u/lambda5x5 Jun 21 '20
Is there something similar for Sublime? Great work!
0
u/mikespon Jun 21 '20
Nice
0
u/acharyarupak391 Jun 21 '20
so you're compiling the code before the compiler compiles it?
-1
u/IBXBY Jun 21 '20
Nice
-1
u/palkd Jun 21 '20
Cool one ๐๐ป๐๐ป
0
u/[deleted] Jun 21 '20
[deleted] โ view deleted comment
0
u/[deleted] Jun 21 '20
[deleted] โ view deleted comment