From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: [PATCH] (Tiny) Tweak Python session null return value Date: Mon, 17 Feb 2020 12:52:43 -0500 Message-ID: References: <87a75hfah9.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000097228e059ec939eb" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:40952) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3kZm-0002Ic-ND for emacs-orgmode@gnu.org; Mon, 17 Feb 2020 12:53:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3kZl-0005XC-DE for emacs-orgmode@gnu.org; Mon, 17 Feb 2020 12:52:58 -0500 In-Reply-To: <87a75hfah9.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: Jack Kamm Cc: Bastien , org-mode-email --00000000000097228e059ec939eb Content-Type: text/plain; charset="UTF-8" I think None is correct. If you don't specify a return value in Python, then a function returns None. I would expect that to happen in a Python block too. John ----------------------------------- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu On Mon, Feb 17, 2020 at 11:25 AM Jack Kamm wrote: > Hi, > > Below is a very small patch to Python session blocks, to make them > return a blank result (empty string) instead of None when there is no > return value. > > Normally I would push this myself, but since we are so close to 9.4, I > thought it prudent to mail a patch and let the maintainers handle it. It > would be nice to include in 9.4, but not a big deal if I've missed the > window. > > Now for an explanation of the patch: 9.4 changes Python session blocks > to fix several bugs and improve robustness overall [0]. However, there > is a cost to these fixes, which is that the session blocks can only > return a result when it is a top-level expression on the last line of > the block. If the last line is not a top-level expression, the block > would previously print "None". However, after some testing, I think this > is a little counter-intuitive, and it would be better if it returned a > blank (empty) result instead of "None". > > [0] https://lists.gnu.org/archive/html/emacs-orgmode/2020-01/msg00190.html > > Best, > Jack > > > --00000000000097228e059ec939eb Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I think None is correct. If you don't specify a return= value in Python, then a function returns None. I would expect that to happ= en in a Python block too.


John

-----------------------= ------------
Professor John Kitchin=C2=A0
Doherty Hall A207F
Depar= tment of Chemical Engineering
Carnegie Mellon University
Pittsburgh, = PA 15213
412-268-7803

<= br>
On Mon,= Feb 17, 2020 at 11:25 AM Jack Kamm <jackkamm@gmail.com> wrote:
Hi,

Below is a very small patch to Python session blocks, to make them
return a blank result (empty string) instead of None when there is no
return value.

Normally I would push this myself, but since we are so close to 9.4, I
thought it prudent to mail a patch and let the maintainers handle it. It would be nice to include in 9.4, but not a big deal if I've missed the<= br> window.

Now for an explanation of the patch: 9.4 changes Python session blocks
to fix several bugs and improve robustness overall [0]. However, there
is a cost to these fixes, which is that the session blocks can only
return a result when it is a top-level expression on the last line of
the block. If the last line is not a top-level expression, the block
would previously print "None". However, after some testing, I thi= nk this
is a little counter-intuitive, and it would be better if it returned a
blank (empty) result instead of "None".

[0] https://lists.gnu.org/arch= ive/html/emacs-orgmode/2020-01/msg00190.html

Best,
Jack


--00000000000097228e059ec939eb--