I'm working on a school project where we are attempting to make a game where the objective is to code in python. We decided on using Java and Jython as our python interpreter, I'm not going to go into much detail about the game here, but you could view it as a glorified python debugger.

We have run into two problems, however:

1: We want to run the user code line by line, but we also want loops and such to a) actually work and b) don't finish instantaneous once they have been completely read by the program. We want to show the effects of the code on screen. In other words, we want to slow the execution down.

Our first idea was to use the python debugger (pdb) and do a simple hack where we would simply feed it an order to "step" at given intervals. In addition to this feeling like a really bad solution, we also couldn't figure out how to do it. Following ideas included extending the debugger itself to continue at given intervals. (A work still in progress) This also meant that we spent some time debugging the python debugger with the python debugger, which completely overwhelmed my brain.

It seems like we keep running into different sets of bad ideas which it turns out we can't figure out how to do. What I would like to know is if anyone could enlighten us of a simple way to do it, and otherwise some tips on best practice.

2: We want to bundle Jython with our game in a single .jar file. The purpose would be for people to be able to "play" the game without having python installed on their computer. This would mean that we also would have to have the python standard library in the bundle. How do I make Jython look inside the jar when it is looking for .py files on import? I've been looking at sys.path and such, am I right in assuming that I will have to make my own module loader thingy, and add it somewhere? Does perhaps such a loader already exist?

We really need some help. Especially on the first problem.
If you have any other insights you think we will want to know about at some point, feel free to share.
I hope someone out there have the know-how to throw us a hint, thanks in advance.