SashaCrofter/swirlypy — pull request #26 by WilCrofter (2014-07-27 17:34:48+00:00)
Title: DON'T MERGE: Shell question which performs all 3 command line functions.

An experimental shell question which performs the three essential functions represented separately by the new variable, get value, and command questions. The experimental question's `test_response()` method merely prints collected data and returns True. There is an associated lesson in `swirlypy/courses/test`. (Sesson reproduced below.)

I doubt that this question is useful as is. Many questions would require only one or two of the essential functions and may prefer to omit irrelevant ones for performance reasons.

The `get_response()` method returns, among other things (see below,) a syntax tree modified by `CaptureExprs().visit()`. This is necessary since the tree is executed in the calling program, but it means that the returned syntax tree won't match the correct answer if the latter is parsed in the regular way.

```
$ utils/swirlytool.py run courses/test
Test Lessons by Swirlypy Authors
1: Basics
2: Tricky
3: Experimental
Selection: 3
Type print('hi')
>>> print('hi')
hi

ast: Interactive(body=[Expr(value=Call(func=Attribute(value=Name(id='__swirlypy_recorder__', ctx=Load()), attr='record', ctx=Load()), args=[Call(func=Name(id='print', ctx=Load()), args=[Str(s='hi')], keywords=[], starargs=None, kwargs=None)], keywords=[], starargs=None, kwargs=None))])

added: {}
changed: {}
removed: {}

values: [None]
Here we create a variable for use in subsequent questions. Set x=10
>>> x = 10

ast: Interactive(body=[Assign(targets=[Name(id='x', ctx=Store())], value=Num(n=10))])

added: {'x': 10}
changed: {}
removed: {}

values: []
What is the value of x?
>>> 10
10

ast: Interactive(body=[Expr(value=Call(func=Attribute(value=Name(id='__swirlypy_recorder__', ctx=Load()), attr='record', ctx=Load()), args=[Num(n=10)], keywords=[], starargs=None, kwargs=None))])

added: {}
changed: {}
removed: {}

values: [10]

Lesson complete!
```