Almenon / AREPL-electron

python scratchpad with real-time code evaluation
MIT License
74 stars 6 forks source link

Actual breakpoints #67

Open Almenon opened 6 years ago

Almenon commented 6 years ago

How breakpoints work currently is..... super hacky, but not in a good way. I simply slice off any text after the breakpoint. In simple cases this is okay but obviously it does not work with functions, whoch may be defined on line 1 yet called on line 100.

Almenon commented 6 years ago

The workaround for this (in the case of AREPL-vscode) is to simply debug it.

Almenon commented 6 years ago

I might be able to do this just by injecting something like the below into the users code:

# define global printLocals func

# later on in code
print(lineNumber, locals())

Or if the user only wants to print locals during a specific iteration:

called=0;called += 1; if called==X: print(lineNumber, locals()) # X being the iteration number
Almenon commented 6 years ago

another way I can use this is by using BDB, the base class for python's pdb debugger.