From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: Babel python question: use of ipython and %cpaste Date: Tue, 03 Dec 2013 12:44:42 +0100 Message-ID: <878uw2upjp.fsf@gmx.us> References: <529D7546.3080500@lbl.gov> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56871) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VnoPX-0003O1-TN for emacs-orgmode@gnu.org; Tue, 03 Dec 2013 06:45:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VnoPR-0005JJ-PZ for emacs-orgmode@gnu.org; Tue, 03 Dec 2013 06:45:03 -0500 Received: from plane.gmane.org ([80.91.229.3]:53751) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VnoPR-0005Ib-IU for emacs-orgmode@gnu.org; Tue, 03 Dec 2013 06:44:57 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1VnoPP-00089K-Un for emacs-orgmode@gnu.org; Tue, 03 Dec 2013 12:44:55 +0100 Received: from ip-pool-138.iue.it ([192.167.90.138]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 03 Dec 2013 12:44:55 +0100 Received: from rasmus by ip-pool-138.iue.it with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 03 Dec 2013 12:44:55 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Arun Persaud writes: > Hi > > being able to use python as a source block is great, but I often stumble > over the fact that when using sessions you have to treat empty lines in > a special way (i.e. as the end of an indentation block). > > I was wondering if it would be easy to create an ipython mode, something > like > > #+BEGIN_SRC ipython ... You can get some of the way already. Personally, I don't see the need of a ipython block as I see IPython as an interpreter. > where the content for a session is copied over to an ipython buffer > using the ipython magic %cpaste. This way empty lines should be treated > correctly. > > It would also have the nice side effect of giving access to other magic > commands within org-babel, such as %timeit or profiling. You could still use python source blocks for this. For python.el I use : (setq python-shell-interpreter "ipython" ;; org mode seems to work better with classic mode. . . python-shell-interpreter-args "--classic --no-banner" python-shell-completion-setup-code "from IPython.core.completerlib import module_completion" python-shell-completion-module-string-code "';'.join(module_completion('''%s'''))\n" python-shell-completion-string-code "';'.join(get_ipython().Completer.all_completions('''%s'''))\n") For Org you could do: (setq org-babel-python-command "ipython --no-banner --classic --no-confirm-exit") You should now be able to do #+BEGIN_SRC python :results output %timeit 1+1 #+END_SRC #+RESULTS: : >>> 10000000 loops, best of 3: 31.5 ns per loop : >>> –Rasmus -- Hooray!