sounds like fun - maybe it's similar to corewars?
i think the easiest way (and most unix-like way)
is to send characters down the debugger's stdin.
that is, send 'n' or 's' to step through a program.
the debugger will let you know where it's up to.
to do this, you can use the python 'subprocess'
module. or whatever facility the JVM gives you
to start a new process and talk to it via a 'pipe'
(google for 'redirect stdin pipe' or something like
alternately (and i don't think preferably), you can
use the standard java debugger to stop when jython
reads a newline. but i'm sure you can do the first
option -- it might feel like a hack, but it's quite
On Thu, Apr 14, 2011 at 4:32 PM, Andreas Johnsen <osthekake@...> wrote:
> 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
> Benefiting from Server Virtualization: Beyond Initial Workload
> Consolidation -- Increasing the use of server virtualization is a top
> priority.Virtualization can reduce costs, simplify management, and improve
> application availability and disaster protection. Learn more about boosting
> the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
> Jython-users mailing list