emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Mixing Python2 and Python3 blocks in one file


From: William Henney
Subject: Re: [O] Mixing Python2 and Python3 blocks in one file
Date: Tue, 17 May 2016 20:19:04 -0500

Hi Karl

On Tue, May 17, 2016 at 9:54 AM, Karl Voit <address@hidden> wrote:
Hi William

* William Henney <address@hidden> wrote:
>
> On Sun, May 8, 2016 at 3:31 AM, Karl Voit <address@hidden> 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 allows
> 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’t think a proliferation of org-babel languages is the answer.  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





--

  Dr William Henney, Instituto de Radioastronomía y Astrofísica,
  Universidad Nacional Autónoma de México, Campus Morelia

reply via email to

[Prev in Thread] Current Thread [Next in Thread]