From mboxrd@z Thu Jan 1 00:00:00 1970 From: William Henney Subject: Re: Mixing Python2 and Python3 blocks in one file Date: Tue, 17 May 2016 20:19:04 -0500 Message-ID: References: <2016-05-08T10-21-00@devnull.Karl-Voit.at> <2016-05-17T16-45-38@devnull.Karl-Voit.at> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a113f64eeb41a22053313a497 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48148) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2qMu-0004iI-Ek for emacs-orgmode@gnu.org; Tue, 17 May 2016 21:33:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b2q8e-0006XP-S9 for emacs-orgmode@gnu.org; Tue, 17 May 2016 21:19:06 -0400 Received: from mail-io0-x229.google.com ([2607:f8b0:4001:c06::229]:33187) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2q8e-0006XL-Ks for emacs-orgmode@gnu.org; Tue, 17 May 2016 21:19:04 -0400 Received: by mail-io0-x229.google.com with SMTP id f89so46561847ioi.0 for ; Tue, 17 May 2016 18:19:04 -0700 (PDT) In-Reply-To: <2016-05-17T16-45-38@devnull.Karl-Voit.at> 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" To: Karl Voit Cc: emacs-org --001a113f64eeb41a22053313a497 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Karl On Tue, May 17, 2016 at 9:54 AM, Karl Voit wrote: > Hi William > > * William Henney wrote: > > > > On Sun, May 8, 2016 at 3:31 AM, Karl Voit wrote: > > > > Python2 and Python3 are two different languages. Unfortunately, > >> Org-mode only uses ~#+BEGIN_SRC python~ for both and uses > >> python-shell-interpreter to choose/switch the compiler. > >> > >> Shouldn't Org-mode introduce ~#+BEGIN_SRC python2~ and ~#+BEGIN_SRC > >> python3~ to solve this issue in a clean way? > >> > >> ~#+BEGIN_SRC python~ can still default to python2. > >> > > You can use the :python header argument to the source block, which allo= ws > > you to specify the path to the python interpreter: > > > > #+BEGIN_SRC python :python /Users/will/anaconda/envs/py27/bin/python > > Cool, I did not find this parameter yet. > > Is this undocumented? http://orgmode.org/org.html does not contain > the string ":python:" and > http://orgmode.org/org.html#Language_002dspecific-header-arguments > also does not mention this parameter. > > It is documented at http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-python.html You are right that it would be better if the language-specific babel documentation were better integrated in the general org info file. But I suppose nobody has been sufficiently motivated to do it yet > > Also see original discussion at > > https://lists.gnu.org/archive/html/emacs-orgmode/2014-04/msg01042.html > > Most interesting to me, thank you. > > With the parameter above as a workaround, I can accomplish the > things I want to do for now. However, I still do think that Python2 > and Python3 as different languages demand different block > identifiers. > > #+BEGIN_SRC python -> defaults to the default python interpreter > #+BEGIN_SRC python2 -> uses Python2 > #+BEGIN_SRC python3 -> uses Python3 > > Don't you think? > > To be honest, I disagree that we need different block identifiers. Python is hardly the only language to have gone through multiple major versions, and I don=E2=80=99t think a proliferation of org-babel languages is the ans= wer. What about C11 vs C99, etc? I guess a good rule of thumb would be: do the two versions use the same major mode in emacs? Why is the :python parameter insufficient for your needs? You can also use it for different virtual environments Cheers Will > -- > mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML to Org-mode: > > get Memacs from https://github.com/novoid/Memacs < > > https://github.com/novoid/extract_pdf_annotations_to_orgmode + more on > github > > > --=20 Dr William Henney, Instituto de Radioastronom=C3=ADa y Astrof=C3=ADsica, Universidad Nacional Aut=C3=B3noma de M=C3=A9xico, Campus Morelia --001a113f64eeb41a22053313a497 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi Karl

On Tue, May 17, 2016 at 9:54 AM, Karl Voit <devnull@karl-voit.at= > wrote:
Hi William

* William Henney <whenney@gmail.com= > wrote:
>
> On Sun, May 8, 2016 at 3:31 AM, Karl Voit <devnull@karl-voit.at> wrote:
>
> Python2 and Python3 are two different languages. Unfortunately,
>> Org-mode only uses ~#+BEGIN_SRC python~ for both and uses
>> python-shell-interpreter to choose/switch the compiler.
>>
>> Shouldn't Org-mode introduce ~#+BEGIN_SRC python2~ and ~#+BEGI= N_SRC
>> python3~ to solve this issue in a clean way?
>>
>> ~#+BEGIN_SRC python~ can still default to python2.
>>
> You can use the :python header argument to the source block, which all= ows
> you to specify the path to the python interpreter:
>
> #+BEGIN_SRC python :python /Users/will/anaconda/envs/py27/bin/p= ython

Cool, I did not find this parameter yet.

Is this undocumented? http://orgmode.org/org.html does not contain the string ":python:" and
http://orgmode.org/org.html#Langua= ge_002dspecific-header-arguments
also does not mention this parameter.

=C2=A0

You are right that it would b= e better if the language-specific babel documentation were better integrate= d in the general org info file.=C2=A0 But I suppose nobody has been suffici= ently motivated to do it yet
=C2=A0
> Also see original discussion at
> https://lists.gnu.org/arc= hive/html/emacs-orgmode/2014-04/msg01042.html

Most interesting to me, thank you.

With the parameter above as a workaround, I can accomplish the
things I want to do for now. However, I still do think that Python2
and Python3 as different languages demand different block
identifiers.

#+BEGIN_SRC python -> defaults to the default python interpreter
#+BEGIN_SRC python2 -> uses Python2
#+BEGIN_SRC python3 -> uses Python3

Don't you think?


To be honest, I disagree that we need different block identifiers.= =C2=A0 Python is hardly the only language to have gone through multiple maj= or versions, and I don=E2=80=99t think a proliferation of org-babel languag= es is the answer.=C2=A0 What about C11 vs C99, etc?=C2=A0 I guess a good ru= le of thumb would be: do the two versions use the same major mode in emacs?=

Why is the :python parameter insufficient for you= r needs?=C2=A0 You can also use it for different virtual environments
=

Cheers

Will

=C2=A0
--
mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML to Org-mode:
=C2=A0 =C2=A0 =C2=A0 =C2=A0> get Memacs from https://github.com/n= ovoid/Memacs <

https://github.com/novoid/extract_pdf_an= notations_to_orgmode + more on github





--
=

=C2=A0 Dr William = Henney, Instituto de Radioastronom=C3=ADa y Astrof=C3=ADsica,
=C2=A0 Uni= versidad Nacional Aut=C3=B3noma de M=C3=A9xico, Campus Morelia
<= /div>
--001a113f64eeb41a22053313a497--