https://github.com/okpy/pytutor
Python Tutor Package
https://github.com/okpy/pytutor
Last synced: about 1 year ago
JSON representation
Python Tutor Package
- Host: GitHub
- URL: https://github.com/okpy/pytutor
- Owner: okpy
- License: other
- Created: 2017-05-07T05:48:54.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2023-09-06T04:55:49.000Z (almost 3 years ago)
- Last Synced: 2025-04-06T23:08:24.977Z (about 1 year ago)
- Language: JavaScript
- Size: 80.1 KB
- Stars: 16
- Watchers: 1
- Forks: 7
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Pytutor
A library for Phillip Guo's (@pgbovine) Python Tutor.

Designed for Python 3
# Installation
`pip install pytutor`
# Usage
## Generating Traces
```
import json
from pytutor import generate_trace, server
modules = {'helper': 'foo = 1'}
setup_code = "y = 4"
trace = generate_trace.run_logger('x = 1 + y' , setup_code , modules)
trace_dict = json.loads(trace)
server.run_server(trace) # Serves HTML
```
```
>>> trace_dict
{
"code": {
"main_code": "x = 1 + y",
"custom_modules": {
"pg_setup": "y = 4"
},
"helper": "foo = 1"
},
"trace": [
{
"line": 1,
"event": "step_line",
"func_name": "",
"file_name": "",
"globals": {
"y": 4
},
"ordered_globals": [
"y"
],
"stack_to_render": [],
"heap": {},
"stdout": ""
},
{
"line": 1,
"event": "return",
"func_name": "",
"file_name": "",
"globals": {
"y": 4,
"x": 5
},
"ordered_globals": [
"y",
"x"
],
"stack_to_render": [],
"heap": {},
"stdout": ""
}
]
}
```
# License
MIT License
# Credits:
Phillip Guo - Python Tutor
Sumukh Sridhara - @sumukh (Modifications to support multiple python files)