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--