From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: setting flags in python src blocks? Date: Wed, 31 Jan 2018 15:47:03 -0800 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="001a1148d714a6f25605641b18ce" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:54862) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eh25r-00083H-B7 for emacs-orgmode@gnu.org; Wed, 31 Jan 2018 18:47:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eh25q-0005Qz-AJ for emacs-orgmode@gnu.org; Wed, 31 Jan 2018 18:47:07 -0500 Received: from mail-wm0-x22a.google.com ([2a00:1450:400c:c09::22a]:37754) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eh25q-0005QG-3Z for emacs-orgmode@gnu.org; Wed, 31 Jan 2018 18:47:06 -0500 Received: by mail-wm0-x22a.google.com with SMTP id v71so2322218wmv.2 for ; Wed, 31 Jan 2018 15:47:05 -0800 (PST) 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: org-mode-email --001a1148d714a6f25605641b18ce Content-Type: text/plain; charset="UTF-8" Is it possible to set command line flags for an executable in src blocks? I was thinking of something like this #+BEGIN_SRC python :flags --some_flag=True :tangle test.py import app print(app.FLAGS.some_flag) # -> True #+END_SRC which would be equivalent to running: > python --some_flag=True test.py Thanks, John ----------------------------------- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu --001a1148d714a6f25605641b18ce Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Is it possible to set command line flags for an executable= in src blocks? I was thinking of something like this=C2=A0

<= div>
#+BEGIN_SRC python :flags --some_flag=3DTrue :tangle test.py
=
import app

print(app.FLAGS.some_flag) # ->= True
#+END_SRC

which would be equivalen= t to running:

> python --some_flag=3DTrue test.= py

Thanks,

John

-------= ----------------------------
Professor John Kitchin=C2=A0
Doherty Hal= l A207F
Department of Chemical Engineering
Carnegie Mellon University=
Pittsburgh, PA 15213
412-268-7803
--001a1148d714a6f25605641b18ce-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yasushi SHOJI Subject: Re: setting flags in python src blocks? Date: Thu, 1 Feb 2018 15:11:40 +0900 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58916) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eh864-0006oS-71 for emacs-orgmode@gnu.org; Thu, 01 Feb 2018 01:11:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eh863-0000k5-4F for emacs-orgmode@gnu.org; Thu, 01 Feb 2018 01:11:44 -0500 Received: from mail-lf0-x231.google.com ([2a00:1450:4010:c07::231]:37617) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eh862-0000js-RZ for emacs-orgmode@gnu.org; Thu, 01 Feb 2018 01:11:43 -0500 Received: by mail-lf0-x231.google.com with SMTP id 63so24388006lfv.4 for ; Wed, 31 Jan 2018 22:11:42 -0800 (PST) In-Reply-To: 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: John Kitchin Cc: org-mode-email Hi, On Thu, Feb 1, 2018 at 8:47 AM, John Kitchin wrote: > Is it possible to set command line flags for an executable in src blocks? I > was thinking of something like this > > #+BEGIN_SRC python :flags --some_flag=True :tangle test.py > import app > > print(app.FLAGS.some_flag) # -> True > #+END_SRC ob-python doesn't suport :flags nor :cmdline, but you can set interpreter with :python. So, you can do #+begin_src python :python "python --some_flag=True" to pass parameter to the interpreter. -- yashi From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: setting flags in python src blocks? Date: Wed, 31 Jan 2018 22:23:32 -0800 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="001a1146f4dcab4d29056420a28f" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:60599) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eh8HZ-0001rE-1I for emacs-orgmode@gnu.org; Thu, 01 Feb 2018 01:23:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eh8HX-0004OD-TI for emacs-orgmode@gnu.org; Thu, 01 Feb 2018 01:23:37 -0500 Received: from mail-wm0-x22f.google.com ([2a00:1450:400c:c09::22f]:56131) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eh8HX-0004Nv-MN for emacs-orgmode@gnu.org; Thu, 01 Feb 2018 01:23:35 -0500 Received: by mail-wm0-x22f.google.com with SMTP id 143so3477360wma.5 for ; Wed, 31 Jan 2018 22:23:35 -0800 (PST) In-Reply-To: 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: Yasushi SHOJI Cc: org-mode-email --001a1146f4dcab4d29056420a28f Content-Type: text/plain; charset="UTF-8" Thanks. That does work for flags the interpreter knows, but python doesn't understand --some_flag (I mean literally that flag!). It turns out I meant: python test.py --some_flag=True. It looks like that is not currently possible. John ----------------------------------- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu On Wed, Jan 31, 2018 at 10:11 PM, Yasushi SHOJI wrote: > Hi, > > On Thu, Feb 1, 2018 at 8:47 AM, John Kitchin > wrote: > > Is it possible to set command line flags for an executable in src > blocks? I > > was thinking of something like this > > > > #+BEGIN_SRC python :flags --some_flag=True :tangle test.py > > import app > > > > print(app.FLAGS.some_flag) # -> True > > #+END_SRC > > ob-python doesn't suport :flags nor :cmdline, but you can set interpreter > with :python. So, you can do > > #+begin_src python :python "python --some_flag=True" > > to pass parameter to the interpreter. > -- > yashi > --001a1146f4dcab4d29056420a28f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks. That does work for flags the interpreter knows, bu= t python doesn't understand --some_flag (I mean literally that flag!).<= div>
It turns out I meant:

python te= st.py --some_flag=3DTrue.

It looks like that is no= t currently possible.

<= div dir=3D"ltr">
John

-------------------------= ----------
Professor John Kitchin=C2=A0
Doherty Hall A207F
Departm= ent of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA= 15213
412-268-7803

On Wed, Jan 31, 2018 at 10:11 PM, Yasushi SH= OJI <yasushi.shoji@gmail.com> wrote:
Hi,

On Thu, Feb 1, 2018 at 8:47 AM, John Kitchin <jkitchin@andrew.cmu.edu> wrote:
> Is it possible to set command line flags for an executable in src bloc= ks? I
> was thinking of something like this
>
> #+BEGIN_SRC python :flags --some_flag=3DTrue :tangle test.py
> import app
>
> print(app.FLAGS.some_flag) # -> True
> #+END_SRC

ob-python doesn't suport :flags nor :cmdline, but you can set in= terpreter
with :python. So, you can do

#+begin_src python :python "python --some_flag=3DTrue"

to pass parameter to the interpreter.
--
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0yashi

--001a1146f4dcab4d29056420a28f--