emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jack Kamm <jackkamm@gmail.com>
To: Ista Zahn <istazahn@gmail.com>
Cc: emacs-orgmode Mailinglist <emacs-orgmode@gnu.org>
Subject: Re: ob-python newline & indentation behavior
Date: Sun, 26 Nov 2017 08:25:39 +0000	[thread overview]
Message-ID: <CADRALHyrrg=VoQV+USAfi51kdzCUYzgxMfGoX4f5F29-fScvGw@mail.gmail.com> (raw)
In-Reply-To: <CA+vqiLF7w0yuVb_3OPFksB0ZnP=1TZWwiNb4WXNoVFR5Q6OF2A@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3556 bytes --]

ob-ipython has a bug which renders it basically unusable to me -- it
crashes when trying to interrupt the kernel with C-c C-c, which is
something I often find myself needing to do (see
https://github.com/gregsexton/ob-ipython/issues/115).

However I agree that ob-ipython is very promising and could lead to
org-babel becoming a viable jupyter notebook alternative in the future.
Having :async execution is especially cool, if somewhat buggy right now. I
hope ob-ipython continues to improve.

Nevertheless, I would like ob-python to work properly, regardless of
ob-ipython, as I like being able to use an python session in emacs without
jupyter.

On Sun, Nov 26, 2017 at 2:45 AM, Ista Zahn <istazahn@gmail.com> wrote:

> ob-ipython[1] provides a working alternative:
>
> #+BEGIN_SRC jupyter-python :session :results output
>   foo = 0
>   for _ in range(10):
>       foo += 1
>
>       foo += 1
>
>   print(foo)
> #+END_SRC
>
> #+RESULTS:
> : 20
>
> I've long wished that more org people would show ob-ipython some love.
> Letting jupyter handle things on the backend seems like it should
> simplifly things considerably.
>
> [1] https://github.com/gregsexton/ob-ipython
>
> Best,
> Ista
>
> On Tue, Nov 21, 2017 at 3:28 AM, Jack Kamm <jackkamm@gmail.com> wrote:
> > Yes, I'm starting to see now how difficult it is to properly support
> > ":session :results value". I would vote to remove it from ob-python...
> >
> > I think the patch still improves ":session :results output" so I will
> > simplify it and restrict to that case, leaving ":session :results value"
> > unchanged for now.
> >
> > Sorry for sending this twice Kyle, forgot to reply all.
> >
> > On 21 Nov 2017 4:04 am, "Kyle Meyer" <kyle@kyleam.com> wrote:
> >>
> >> Jack Kamm <jackkamm@gmail.com> writes:
> >>
> >> > In response to this:
> >> >
> >> >> I can't think of a good solution, though.  Stepping back a bit, I
> think
> >> >> it's unfortunate that python blocks handle ":results value"
> differently
> >> >> depending on whether the block is hooked up to a session or not.  For
> >> >> non-sessions, you have to use return.  Using the same approach
> >> >> (org-babel-python-wrapper-method) for ":session :results value", we
> >> >> could then get the return value reliably, but the problem with this
> >> >> approach is that any variables defined in a ":results value" block
> >> >> wouldn't be defined in the session after executing the block because
> >> >> the
> >> >> code is wrapped in a function.
> >> >
> >> > How about if we used the "globals()" and "locals()" functions in
> Python?
> >> >
> >> > Something like this at the end of the wrapper block, before return:
> >> >
> >> > for k, v in locals().items():
> >> >     globals()[k] = v
> >>
> >> Hmm, placing that code "before return" is a problem.  Like with
> >> non-session ":results value" blocks, the user would be responsible for
> >> inserting the return (or even multiple return's), so we can't know where
> >> to insert the above code without parsing the block :/
> >>
> >> > Another bug with the current approach is that it breaks if common
> idioms
> >> > like "for _ in range(10)" are used. ("_" is used to inspect the last
> >> > output
> >> > of the shell, an obscure feature I hadn't known about until now).
> >>
> >> Right.  Also, IIRC the built-in interactive python and ipython treat
> >> multiline blocks differently.  With
> >>
> >>     if True:
> >>         "ipython ignores my existence"
> >>
> >> the built-in shell binds "_" to the string's value, but ipython doesn't.
> >>
> >> --
> >> Kyle
>

[-- Attachment #2: Type: text/html, Size: 5080 bytes --]

  reply	other threads:[~2017-11-26  8:25 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-18 12:02 ob-python newline & indentation behavior Jack Kamm
2017-11-18 15:05 ` Kyle Meyer
2017-11-18 22:15   ` Jack Kamm
2017-11-19  3:27     ` Martin Alsinet
2017-11-19  3:34       ` Martin Alsinet
2017-11-19  7:41         ` Jack Kamm
2017-11-20  6:25           ` Kyle Meyer
2017-11-20 21:31             ` Jack Kamm
2017-11-21  4:04               ` Kyle Meyer
2017-11-21  8:28                 ` Jack Kamm
2017-11-26  2:45                   ` Ista Zahn
2017-11-26  8:25                     ` Jack Kamm [this message]
2017-11-26  8:15                   ` Jack Kamm
2017-11-27  4:00                     ` Kyle Meyer
2017-12-09 12:12                       ` John Kamm
2017-12-18  8:22                         ` Jack Kamm
2017-12-18 11:44                           ` Kyle Meyer
2017-12-19  5:11                             ` Kyle Meyer
2017-11-19 17:17     ` 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='CADRALHyrrg=VoQV+USAfi51kdzCUYzgxMfGoX4f5F29-fScvGw@mail.gmail.com' \
    --to=jackkamm@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=istazahn@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).