- Add basic support for flags and frames.
- Add basic support for
lambda
functions. - Add basic support for user-defined objects.
- Address existing bugs in PythonTutor:
- Fix the frame-id bug in pg_logger. (See Fall 2017, MT2 Q2.)
- Make sure
__str__
and__repr__
are executed when appropriate. (Right now, PythonTutor doesn't go into__repr__
if you callprint
without a__str__
function.)
lambda
functions should have subscripts (as in your textbook), so people can tell them apart easily.- When you come across a
lambda
function, perhaps you can somehow turn it into a non-anonymous function. (For instance, maybe you can wrap it in a unique no-op which gives it an identity? Or change its.__name__
attribute, if it has one?) - You might be able to do this by walking the AST and transforming the
lambda
nodes. (Every AST node has not only alineno
but also acol_offset
, which may be handy.)
- When you come across a
- Objects should be rendered as in the "OOP" chapter of your textbook.
- Consider how to render bound methods. (This'll take some experimenting in the interpreter too, to figure out how Python handles bound methods.)
- Iterators should be rendered as in the "Iterators & Generators" chapter of your textbook.
- Generators should be rendered as in the "Iterators & Generators" chapter of your textbook, but with a slight modification. Each generator object should get its own frame (similar to the way that you render instances for OOP diagrams), to keep track of the local variables specific to that generator instance.
<listcomp>
,<dictcomp>
,<setcomp>
, etc. should either be rendered well, or not rendered at all. (For example, see how PythonTutor does[str(x) for x in range(4)]
. It's horrible. ".0" gets bound to the iterator object and the return values of thestr(x)
don't appear until the very end!)- These correspond to
ListComp
,SetComp
,GeneratorExp
,DictComp
, andcomprehension
nodes in the AST.
- These correspond to
- If you see
f(*args)
, the flag should showargs
being bound to a tuple of all the provided arguments.- This corresponds to a
Starred
node in the AST.
- This corresponds to a
- Handle
import
statements.- See how PythonTutor does it. Only a few modules are "legal".
import
statements correspond to theImport
,ImportFrom
, andalias
nodes in the AST.
- Add support for f-strings.
- The code should be on the left, and the diagram on the right.
- At the bottom of the right panel there should be a
Print Output
box, so as to support print statements. (Perhaps you can find a way to let people adjust its height to be taller or shorter, too.) - At the bottom of the left panel there should a few options that change the way the diagram gets rendered.
- [Default ON] Draw values / arrows under each operand / operator in the flag.
- [Default ON] Draw fancy linked lists, trees, and graphs.
- Release a pip module called
pyagram
, so people can writeimport pyagram as pg
. It should just include simpleLink
,Tree
, andGraph
classes.- People should be able to view their implementations somewhere, perhaps inside your textbook.
- For the
pyagram.Graph
implementation, you should have a mainGraph
class whose__init__
method merely defers to either itsUndirectedGraph
subclass or itsDirectedGraph
subclass, depending on whether the user has supplied edge weights.
- Then, when people instantiate a
pyagram.Link
(and the option is ON), saidpyagram.Link
will get rendered as in CS 61A (box-and-pointer style) rather than the manner in which you typically render user-defined objects / instances in Pyagram. The same principle goes for instances ofpyagram.Tree
. Forpyagram.Graph
instances you can make up your own fancy visualization, as there's no precedent in CS 61A — for instance, you could render apyagram.Graph
as a pointer to a big box, in which you can see all the graph's vertices and edges with labels.
- Release a pip module called
- [Default OFF] Go into
__str__
and__repr__
methods.- Off by default, because it'd otherwise be super annoying every time you call
print
. But it's important that CS 61A students can visualize__str__
and__repr__
when they get to OOP.
- Off by default, because it'd otherwise be super annoying every time you call
- At the bottom of the right panel there should be a
- When you modify the code (or change any of the options on the left panel), the diagram should get a semi-opaque overlay to indicate it's out of date.
- Make everything aesthetically pleasing.
- Display
lambda
functions asλ
instead of<lambda>
. - Some things are not labeled well. For instance, why label a frame "frame 1: f"? It doesn't correspond to the function f; it corresponds to the function call f(5). So how about "frame 1: f(5)"? (Or maybe just "frame 1" if that's too repetitive, given that the flag already communicates that?)
- Etc.
- Display
- Consider colour coding (to distinguish between primitives, lists, instances, frames, etc.).
- Shareable links. (This is important for people to be able to send them to friends or post them on Piazza.) The URL can either contain the code the user wrote, its Burrows-Wheeler transform, or the serialization of the diagram itself.
- Embeddable links, or some way to download a sequence of SVGs that correspond to the diagram. (This is important so you can use them in your textbook.)