From: Kyle Meyer <kyle@kyleam.com>
To: "Ondřej Grover" <ondrej.grover@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Proposal and RFC for improving ob-python
Date: Thu, 10 Dec 2015 02:22:13 -0500 [thread overview]
Message-ID: <87y4d2py3e.fsf@kyleam.com> (raw)
In-Reply-To: <CAOyjJOK=GuySwQXa42LuwvFw0rt5=zP9hGhyH5-iJA5SoWjLNA@mail.gmail.com> ("Ondřej Grover"'s message of "Sat, 5 Dec 2015 18:17:15 +0100")
Ondřej Grover <ondrej.grover@gmail.com> writes:
[...]
> The ob-ipython project tries to solve this hackiness in a different way by
> using the client-server infrastructure of IPython/Jupyter. That works quite
> well too, but my hope is that improving ob-python.el would also make it
> simpler to use IPython as the python REPL, relying only on the core of the
> Python language.
As I understand it (and if I'm remembering correctly), there are at
least three issues with ob-python sessions:
1. Shell prompt markers leak into the output.
2. Whitespace at the beginning of the output is swallowed.
3. Valid code that has indentation and spaces cannot be sent.
I think the first one is the race conditions that ob-ipython.el's README
refers to.
> It essentially boils down to implementing progn-like eval() function in
> Python which would return the result of the last statement if it is an
> expression.
[...]
> My proposal is to implement an equivalent of the following bash pseudo code
> for non session mode
>
> python -i << HEREDOC_END
> ret = block_eval("""
> <CODE BLOCK BODY>
> """)
> open(<TMP FILE or PIPE>).write(str(ret))
> HEREDOC_END
So for non-session code and value results, the main idea is to get rid
of the need for "return" at the end?
This seems useful to me. Requiring a trailing "return", which is a
syntax error when the code is taken by itself, is a quirk of the
implementation (the code ends up being wrapped in a function to get the
return value). Also, it would allow switching from ":results value" to
":results output" without needing to remove "return" in order to avoid a
syntax error.
> For session mode it would be even simpler, lines containing HEREDOC above
> would be dropped and the rest piped directly into the Python REPL.
>
> This also means that the 'org_babel_python_eoe' string indicator may not be
> necessary anymore because end of evaluation would be simply shown by a new
> line with the primary prompt appearing.
But what about when :results != value? Doesn't your proposal only
handle returning the last value?
--
Kyle
next prev parent reply other threads:[~2015-12-10 7:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-05 17:17 Proposal and RFC for improving ob-python Ondřej Grover
2015-12-10 7:22 ` Kyle Meyer [this message]
2016-08-29 12:53 ` Greg Minshall
2016-08-30 19:17 ` John Kitchin
2016-08-31 2:44 ` Greg Minshall
-- strict thread matches above, loose matches on Subject: below --
2015-12-07 19:22 Ondřej Grover
2015-12-07 20:27 ` Kyle Meyer
2015-12-08 7:43 ` Ondřej Grover
2015-12-07 20:36 ` Thomas S. Dye
2015-12-07 20:51 ` Achim Gratz
2015-12-10 7:47 Ondřej Grover
2015-12-11 3:39 ` Kyle Meyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y4d2py3e.fsf@kyleam.com \
--to=kyle@kyleam.com \
--cc=emacs-orgmode@gnu.org \
--cc=ondrej.grover@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).