| 
					
				 | 
			
			
				@@ -157,6 +157,20 @@ Emacs-lisp table, otherwise return the results as a string." 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   "Return the buffer associated with SESSION." 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   (cdr (assoc session org-babel-python-buffers))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+(defun org-babel-python-with-earmufs (session) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  (let ((name (if (stringp session) session (format "%s" session)))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    (if (and (string= "*" (substring name 0 1)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	     (string= "*" (substring name (- (length name) 1)))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	name 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      (format "*%s*" name)))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+(defun org-babel-python-without-earmufs (session) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  (let ((name (if (stringp session) session (format "%s" session)))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    (if (and (string= "*" (substring name 0 1)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	     (string= "*" (substring name (- (length name) 1)))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	(substring name 1 (- (length name) 1)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      name))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 (defvar py-default-interpreter) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 (defun org-babel-python-initiate-session-by-key (&optional session) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   "Initiate a python session. 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -170,8 +184,11 @@ then create.  Return the initialized session." 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        ((and (eq 'python org-babel-python-mode) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	     (fboundp 'run-python)) ; python.el 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	(if (version< "24.1" emacs-version) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	    (let ((python-shell-buffer-name python-buffer)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	      (run-python org-babel-python-command)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	    (progn 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	      (unless python-buffer (org-babel-python-with-earmufs session)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	      (let ((python-shell-buffer-name 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		     (org-babel-python-without-earmufs python-buffer))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		(run-python org-babel-python-command))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	  (run-python))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        ((and (eq 'python-mode org-babel-python-mode) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	     (fboundp 'py-shell)) ; python-mode.el 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -187,7 +204,7 @@ then create.  Return the initialized session." 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			  (concat "Python-" (symbol-name session)))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	       (py-which-bufname bufname)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	  (py-shell) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	  (setq python-buffer (concat "*" bufname "*")))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	  (setq python-buffer (org-babel-python-earmufs bufname)))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        (t 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	(error "No function available for running an inferior Python"))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       (setq org-babel-python-buffers 
			 |