Advice for using emacs python-mode

Andrew Koenig ark at research.att.com
Wed Nov 20 17:09:04 EST 2002


Syver> Hi Andrew, I've been where you are, and it's not a great place
Syver> to be. One thing I did was to put Python Output into a separate
Syver> frame (another toplevel window). This keeps the main frame of
Syver> emacs more stable.

Syver> (setq special-display-buffer-names '("*Python*" "*Python Output*"))

Ah.  Yes, that would be quite a help.  I didn't know about that
variable.  However, I do think that it would be better if python-mode
would check whether an appropriately named window already exists and,
if so, leave it alone.

Syver> The other problem (when running the interpreter and the module needs
Syver> to be reloaded), I solved by not using that feature much. I've instead
Syver> bound a key to an lisp function that uses compile mode to run the
Syver> current python file. I find that this solution solves two problems, it
Syver> doesn't freeze emacs and it avoids the problems with reloading.

Syver> (defun py-unittest ()
Syver>   "run unittest on file in the current bufffer "
Syver>   (interactive)
Syver>   (compile 
Syver>    (format "python \"%s\""
Syver> 	   (buffer-file-name))))

I suppose.

Syver> The thing about it running unittest on the current buffer really is a
Syver> lying comment. It just so happens that all my modules have a
Syver> if __name__ == '__main__':
Syver>      unittest.main()

Syver> in the bottom of them, so that running them as a main program is the
Syver> same as running the unittests contained in the file.

Gotcha.

Syver> In addition if you want to be able to step around your source for
Syver> tracebacks in the compilation buffer:
Syver> ;; python TraceBack
Syver> ;;   File "h:/mydocuments/Kode/pythonscript/AdoDb.py", line 496
Syver> (add-to-list 'compilation-error-regexp-alist
Syver>              '(".*File \"\\(.+\\)\", line \\([0-9]+\\)" 1 2))

Ah; I take it the default isn't right.

Syver> Hope this helps.

Indeed -- thanks!

Maybe I should just use Idle instead :-)

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



More information about the Python-list mailing list