I couldn’t get the above approach to work well with multiple cells containing python code, so I worked out something a little different:
There I’ve written a function runBrython
which takes a string of python code and then evaluates it. This follows the discussion in this Brython issue and uses this trick for running eval
non-strictly.