emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] ob-python :results value pp does not working
@ 2021-12-29  2:58 Christopher M. Miles
  2021-12-30 17:11 ` Jack Kamm
  0 siblings, 1 reply; 5+ messages in thread
From: Christopher M. Miles @ 2021-12-29  2:58 UTC (permalink / raw)
  To: Org Mode

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


The bellowing python source block ~:results value pp~ does not print pprint formated result as
expected. I tested with =$ emacs -q= confirmed this problem.

  #+begin_src python :results value pp
  dic = {'key1': 1, 'b': 2}
  dic
  #+end_src
  
  #+RESULTS[(2021-12-29 10:51:14) b1011bfee8a1636204f73e13367d3b6d2cb6a36e]:
  : None


-- 
[ stardiviner ]
       I try to make every word tell the meaning that I want to express.

       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner, Matrix: stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [BUG] ob-python :results value pp does not working
  2021-12-29  2:58 [BUG] ob-python :results value pp does not working Christopher M. Miles
@ 2021-12-30 17:11 ` Jack Kamm
  2021-12-31  2:33   ` Christopher M. Miles
  0 siblings, 1 reply; 5+ messages in thread
From: Jack Kamm @ 2021-12-30 17:11 UTC (permalink / raw)
  To: numbchild, Org Mode

For non-session Python blocks, you need to use "return" on the value, as
if you are in a function.

The following works for me:

#+begin_src python :results value pp
  dic = {'key1': 1, 'b': 2}
  return dic
#+end_src

#+RESULTS:
: {'b': 2, 'key1': 1}


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [BUG] ob-python :results value pp does not working
  2021-12-30 17:11 ` Jack Kamm
@ 2021-12-31  2:33   ` Christopher M. Miles
  2022-01-01  5:57     ` Jack Kamm
  0 siblings, 1 reply; 5+ messages in thread
From: Christopher M. Miles @ 2021-12-31  2:33 UTC (permalink / raw)
  To: Jack Kamm; +Cc: Org Mode

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


Thanks Jack. Confirmed works. This might need to mentioned in Org manual and in ob-python.el source
code with comment. WDYT?

Jack Kamm <jackkamm@gmail.com> writes:

> For non-session Python blocks, you need to use "return" on the value, as
> if you are in a function.
>
> The following works for me:
>
> #+begin_src python :results value pp
>   dic = {'key1': 1, 'b': 2}
>   return dic
> #+end_src
>
> #+RESULTS:
> : {'b': 2, 'key1': 1}


-- 
[ stardiviner ]
       I try to make every word tell the meaning that I want to express.

       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner, Matrix: stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [BUG] ob-python :results value pp does not working
  2021-12-31  2:33   ` Christopher M. Miles
@ 2022-01-01  5:57     ` Jack Kamm
  2022-01-01 13:52       ` [SOLVED] " Christopher M. Miles
  0 siblings, 1 reply; 5+ messages in thread
From: Jack Kamm @ 2022-01-01  5:57 UTC (permalink / raw)
  To: Christopher M. Miles; +Cc: Org Mode

Hi Christopher,

> This might need to mentioned in Org manual and in ob-python.el source
> code with comment. WDYT?

The main documentation for this is in the Worg page for ob-python, in
particular see the section "Return values":

https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-python.html

I think that is the appropriate place to put this sort of documentation
(i.e. usage of specific babel languages). However, the clarity of this
documentation could be improved; contributions on that would be very
welcome.

In addition, this is also mentioned in the Org manual on return values
in Org babel, "Results of Evaluation":

    For languages like Python, an explicit ‘return’ statement is
    mandatory when using ‘:results value’.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [SOLVED] Re: [BUG] ob-python :results value pp does not working
  2022-01-01  5:57     ` Jack Kamm
@ 2022-01-01 13:52       ` Christopher M. Miles
  0 siblings, 0 replies; 5+ messages in thread
From: Christopher M. Miles @ 2022-01-01 13:52 UTC (permalink / raw)
  To: Jack Kamm; +Cc: Org Mode

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


Jack Kamm <jackkamm@gmail.com> writes:

> Hi Christopher,
>
>> This might need to mentioned in Org manual and in ob-python.el source
>> code with comment. WDYT?
>
> The main documentation for this is in the Worg page for ob-python, in
> particular see the section "Return values":
>
> https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-python.html
>
> I think that is the appropriate place to put this sort of documentation
> (i.e. usage of specific babel languages). However, the clarity of this
> documentation could be improved; contributions on that would be very
> welcome.
>
> In addition, this is also mentioned in the Org manual on return values
> in Org babel, "Results of Evaluation":
>
>     For languages like Python, an explicit ‘return’ statement is
>     mandatory when using ‘:results value’.

I see, thanks. problem solved.

-- 
[ stardiviner ]
       I try to make every word tell the meaning that I want to express.

       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner, Matrix: stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-01-01 14:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-29  2:58 [BUG] ob-python :results value pp does not working Christopher M. Miles
2021-12-30 17:11 ` Jack Kamm
2021-12-31  2:33   ` Christopher M. Miles
2022-01-01  5:57     ` Jack Kamm
2022-01-01 13:52       ` [SOLVED] " Christopher M. Miles

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