* [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
[not found] <m2ilv8i09x.fsf@numbchild>
@ 2021-12-29 3:00 ` Christopher M. Miles
0 siblings, 0 replies; 5+ messages in thread
From: Christopher M. Miles @ 2021-12-29 3:00 UTC (permalink / raw)
To: Org Mode
[-- Attachment #1: Type: text/plain, Size: 1127 bytes --]
"Christopher M. Miles" <numbchild@gmail.com> writes:
> [[PGP Signed Part:Undecided]]
>
> 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
Sorry forget to fill environment information:
- Emacs version: GNU Emacs 28.0.60 (build 1, aarch64-apple-darwin20.6.0, NS appkit-2022.60 Version 11.6 (Build 20G165)) of 2021-10-20
- Org mode version: Org mode version 9.3.4 (release_9.3.4-644-g14d358.dirty @ /Users/stardiviner/Code/Emacs/org-mode/lisp/)
- System: macOS Big Sur 11.6.1
- Python: Anaconda python3 /Users/stardiviner/opt/anaconda3/bin/python
--
[ 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 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
0 siblings, 0 replies; 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
end of thread, other threads:[~2022-01-01 5:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <m2ilv8i09x.fsf@numbchild>
2021-12-29 3:00 ` [BUG] ob-python :results value pp does not working Christopher M. Miles
2021-12-29 2:58 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
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).