From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jack Kamm Subject: Re: Make ob-python.el support ":results pp" pretty print result Date: Sat, 22 Feb 2020 09:21:12 -0800 Message-ID: <87r1ymk06v.fsf@gmail.com> References: <87y2sx6yvl.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:41165) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j5YTx-0003BX-BB for emacs-orgmode@gnu.org; Sat, 22 Feb 2020 12:22:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j5YTw-0004AO-3r for emacs-orgmode@gnu.org; Sat, 22 Feb 2020 12:22:25 -0500 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]:43771) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j5YTv-00049Z-TO for emacs-orgmode@gnu.org; Sat, 22 Feb 2020 12:22:24 -0500 Received: by mail-pf1-x42a.google.com with SMTP id s1so2985764pfh.10 for ; Sat, 22 Feb 2020 09:22:23 -0800 (PST) In-Reply-To: <87y2sx6yvl.fsf@gmail.com> 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-mx.org@gnu.org Sender: "Emacs-orgmode" To: numbchild@gmail.com, Org Mode Hi stardiviner, stardiviner writes: > I found ob-python does not support ":results pp" pretty print result. And Python > has a module "pprint". What about add support this? ":results pp" works for me, here's an example: > #+begin_src python :results pp > return globals() > #+end_src > > #+RESULTS: > #+begin_example > {'__annotations__': {}, > '__builtins__': , > '__cached__': None, > '__doc__': None, > '__file__': '', > '__loader__': , > '__name__': '__main__', > '__package__': None, > '__spec__': None, > 'main': , > 'pprint': } > #+end_example Here's how it looks by default (without "pp"): > #+begin_src python > return globals() > #+end_src > > #+RESULTS: > | __name__ | : | __main__ | __doc__ | : | hline | __package__ | : | hline | __loader__ | : | | __spec__ | : | hline | __annotations__ | : | nil | __builtins__ | : | | __file__ | : | | __cached__ | : | hline | main | : | | And here's how it looks when using ":results output": > #+begin_src python :results output > print(globals()) > #+end_src > > #+RESULTS: > : {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': , '__spec__': None, '__annotations__': {}, '__builtins__': , '__file__': '', '__cached__': None} I also tested this on ":session" blocks and the results were the same.