Advice for using emacs python-mode

Andrew Koenig ark at research.att.com
Wed Nov 20 14:55:52 EST 2002


I'm writing a program using Emacs and python-mode, and have run into
a few problems.

The first problem is what happens when I type C-c C-c to execute my
program: My editor window splits in half, with the bottom half
becoming the *Python Output* buffer, and the output appears there.

That's all well and good.  However, if I now make a second editor
frame, and display the *Python Output* buffer in that frame, C-c C-c
still splits my editor window and creates a second view into the
*Python Output* buffer.  How do I make it stop?

One way seems to be to type C-c ! to start up a Python interpreter
window.  When I do that, I can put the window where I want and it
stays there.  However, that technique creates a new problem.

My program has gotten big enough that I want to split it into two
source files.  In particular, I've split the test code into a separate
file.  The structure looks like this:

        file foo.py:

            if __name__ == "__main__":
                import footest
                footest.main()

        file footest.py:

            from foo import *

            def main():
                # all the test code goes here

            if __name__ == "__main__":
                main()

This strategy has the desirable property that if I want to use the
code foo.py (which is intended to be a library), I don't have to
import and compile all of the test code.  However, it also has a
problem: It appears that if I change code in foo.py, and type C-c C-c,
that change is not necessarily reflected in the program's execution.
I am guessing that under some circumstances, what is happening is that
the code is not getting re-imported.

So I suspect I'm doing something wrong, but don't know what.  Can
someone on this group advise me?  Here are the properties I'd like:

        1) My library code is in one file; my test code in another.

        2) If I type C-c C-c in the window with the library code,
           it runs the test code on the current version of the library
           code--ideally, even if I haven't explicitly saved the
           revisions since last time.

        3) If I make a window that contains the *Python Output* buffer
           (or whatever), it stays there.

Any suggestions?

-- 
Andrew Koenig, ark at research.att.com, http://www.research.att.com/info/ark



More information about the Python-list mailing list