 
 See the `\\[py-shell]' docs for additional warnings."
   (interactive "r")
-  (or (< start end) (error "Region is empty"))
+  (or (< start end)
+      (error "Region is empty"))
   (let ((pyproc (get-process "Python"))
 	fname)
     (if (null pyproc)
-	(shell-command-on-region start end py-python-command)
+	(let ((outbuf "*Python Output*"))
+	  (shell-command-on-region start end py-python-command outbuf)
+	  (save-excursion
+	    (set-buffer outbuf)
+	    ;; TBD: ???
+	    (goto-char (point-max))))
       ;; else feed it thru a temp file
       (setq fname (py-make-temp-name))
       (write-region start end fname nil 'no-msg)

;; - Add a py-goto-error or some such that would scan an exception in
;;   the py-shell buffer, and pop you to that line in the file.

;; If you can think of more things you'd like to see, drop me a line.
;; If you want to report bugs, use py-submit-bug-report (C-c C-b).
;;
;; Note that I only test things on XEmacs 19 and to some degree on
;; Emacs 19.  If you port stuff to FSF Emacs 19, or Emacs 18, please
;; send me your patches.  Byte compiler complaints can probably be
;; safely ignored.

;;; Code:

(require 'custom)

  (switch-to-buffer-other-window (make-comint "Python" py-python-command))
  (make-local-variable 'comint-prompt-regexp)
  (setq comint-prompt-regexp "^>>> \\|^[.][.][.] ")
  (set-process-filter (get-buffer-process (current-buffer)) nil)
  (set-syntax-table py-mode-syntax-table)
  (local-set-key [tab] 'self-insert-command))

