From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id ODKwDcAc3GZV6QAA62LTzQ:P1 (envelope-from ) for ; Sat, 07 Sep 2024 09:28:32 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id ODKwDcAc3GZV6QAA62LTzQ (envelope-from ) for ; Sat, 07 Sep 2024 11:28:32 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1725701312; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=tqIfsM82MWx8kNp7dPcQFvwiPA9Ii1alRr9u7BQE7cI=; b=tM+qlNE1EhFT9knPfvriEXpOVRPDWg/PU/ttq+LcC/kUD17AqaF3/CsBwRDDc3JNQWyypl p0w9iY7mtj0nkd5aY0ONfPYvgrC88RGyznAF+X1CzQoWCeJGwtBF1+PWEvc0wQkfT5khCX i9IyUUWKm1kkYSIBYj5BffS0z+uCw2A7Uq39DU5S/Mh+Pi2waHDoFcuI43a7DqUFF5x5ME GPXqQzqXjOvDvROC7kO+tDYR5XiKZZ4GiQXkBntq/6RowGIXi/Ya8G6hgPANjtaGkjKKA/ hSXJAH2eIYJsK64o7mNpxZgZLtOJAcTR9DrsO5TruM2049BvK8KsY4CI8dHP6g== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1725701312; a=rsa-sha256; cv=none; b=Fh39mRJ/s/Evi/1+3sz47Phf63Zd1dEKfnHbMTGp2gjHXWS1dU304KgtC9/KiGIzUaqZUi YnB9Orb1zK4y9B75eYrTwGzOz9bg6A4esS7Zl+yeVldoUS7+s9u/QSfIZvkJn5Kn+I2yXr WLiPNnlwrqmKNwGQiZKEpUzKUX4/Sx+XmM5nFPcOvqm+pH3Jbv10bzqK22IqpM5JrGCxa+ +BX5UfAWeKlCT9CghQYR5szFa4Wi3XCzoHb4WSCqIrrjN2j94NLk9fqHhwCJ4jy1unVuvj /H30n+DMqau+f36r+xQza4PjW3kdqIzQusPfMtjJ5vDGuwEK6LQD0VvRVbkjPQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id BCE7066D9D for ; Sat, 7 Sep 2024 11:28:31 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1smrjV-0008IS-7g; Sat, 07 Sep 2024 05:27:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1smrjT-0008II-Gb for emacs-orgmode@gnu.org; Sat, 07 Sep 2024 05:27:51 -0400 Received: from k-7.ch ([185.31.100.96]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1smrjR-0003Nw-FL for emacs-orgmode@gnu.org; Sat, 07 Sep 2024 05:27:51 -0400 Received: from van (_gateway [192.168.1.1]) (Authenticated sender: seb) by k-7.ch (Postfix) with ESMTPSA id 2C68FE8129; Sat, 7 Sep 2024 11:27:40 +0200 (CEST) From: =?utf-8?Q?S=C3=A9bastien_Gendre?= To: Rudolf =?utf-8?Q?Adamkovi=C4=8D?= Cc: emacs-orgmode@gnu.org Subject: Re: Org Babel says 1 + 1 in Python is None In-Reply-To: ("Rudolf =?utf-8?Q?Adamkovi?= =?utf-8?Q?=C4=8D=22's?= message of "Fri, 06 Sep 2024 15:33:32 +0200") References: User-Agent: mu4e 1.12.1; emacs 29.4 Date: Sat, 07 Sep 2024 11:27:39 +0200 Message-ID: <87wmjnbypg.fsf@k-7.ch> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Received-SPF: pass client-ip=185.31.100.96; envelope-from=seb@k-7.ch; helo=k-7.ch X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Queue-Id: BCE7066D9D X-Migadu-Scanner: mx12.migadu.com X-Migadu-Spam-Score: -8.59 X-Spam-Score: -8.59 X-TUID: v2NZelK4LB2P --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable But, 1 + 1 should be 11. Joke aside, for Python, how you return the value depend of if you use a session or not. By default, a Python code block do not use a session. In this case, when executed, the code is wrapped into a Python function and then this function is called. So, to return a value, you need to use the "return" statement. With your example: src_python{return 1 + 1} When you use a session for your code block, the last statement value is returned if it is a top level expression. In this case, you do not use a "return" statement. Is it the article you have read on WORG=C2=A0? https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-python.html The part you have quoted maybe miss a reference to the section who explain how the return mechanism work for values. Best regards =2D------ Gendre S=C3=A9bastien Rudolf Adamkovi=C4=8D writes: > Today, I decided to start using Python in Org. > > (1) I read in "WORG": > > :results {output, value}: [...] Value results are the value of the > last expression evaluated in the code block. Value mode is the default > (as with other languages). > > (2) So, I try it, and get: > > src_python{1 + 1} {{{results(=3DNone=3D)}}} > > I expected this to be 2. > > Questions: > > - Who is correct: (1) the documentation or (2) the implementation? > - If (2) is correct, do I have to write `return' every time? > > Rudy --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQI/BAEBCAApFiEEaA9vw9ypVj1kP0tAtYb3x3I54p4FAmbcHIsLHHNlYkBrLTcu Y2gACgkQtYb3x3I54p59Kw/+O4xrV9x8CVLoJ4fLrJoRARMWqTcedS1BgjFusOXC DqTGU5mjvpynb5pqZiAxlBwRrpaUEJPgV6MZv2I0PaEPjI54R6gZvq0VEbHjI6SO emdSqmqkS85rPQLiB9pSWvo2dvZXpx+vGgfGf7jAkX41uvowcG6wcRmjNkMDWkRb r6F6fkh8BqM7e1gbRPvbJh+Eerec5AmqzzsTe3lXvss60IHyrSXoT/D5l9GKErm/ XtBv8J3qdLAQlHh8h9dDMyKFKd94kFA4x4fPImpSiand2Ravatef6Mx33FzjTyiI L3pflk/ZuQUhP0ERD/N0KY7Bm/jIRuM4lEHbvvpGUx5ExPUGf9E0KiGGoDZ2/TED aIqiGxbMqWVVU+2D2lYZK/ae/DZAdFP+hxU0WmvBzCmKJTqnuER+PCKrOQg+xsXC pl3pO6sF6O7x/Oezzi2ICBO4zQfW0g1eM1GHVfwDPbZUrEgLDEWG2F89mVQGZJbs lINFgcRPWiojIRPYiBC7uM4MsaED3BgpUFUL+oZifjj+FOKH/A6mijoK7BuS5fJO 87aAwxc0tE6WZh6QNZ+8jlH07URIDRe5uQI5opOh27I+f4zBtYzeUV6hqH7CuF5B 8o0LFHiy1ztoHcKsx6Ftr544zxLq54k4FhDdjiYisBfy7853bjVtnzEU2KSM5o0R L4E= =AT0U -----END PGP SIGNATURE----- --=-=-=--