From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aaron Ecay Subject: Re: Bug? Improper interaction with python variable _ ? Date: Thu, 29 Oct 2015 14:05:07 +0000 Message-ID: <87pozxydm4.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50663) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrnpS-0008TS-R7 for emacs-orgmode@gnu.org; Thu, 29 Oct 2015 10:05:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZrnpK-00031k-Tl for emacs-orgmode@gnu.org; Thu, 29 Oct 2015 10:05:22 -0400 Received: from mail-wi0-x231.google.com ([2a00:1450:400c:c05::231]:37378) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrnpK-00031I-Nq for emacs-orgmode@gnu.org; Thu, 29 Oct 2015 10:05:14 -0400 Received: by wicfv8 with SMTP id fv8so44039184wic.0 for ; Thu, 29 Oct 2015 07:05:14 -0700 (PDT) In-Reply-To: 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.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Brian Beckman , emacs-orgmode@gnu.org Hi Brian, 2015ko urriak 5an, Brian Beckman-ek idatzi zuen: >=20 > Please see the gist below for a self-explaining example > copied here for convenience. Emacs 24.5.1 with org-mode > 8 something (not sure how to get it to report its exact > version)... a very late version, I am sure. Verified with > no init.el, that is, with emacs -Q >=20 > https://gist.github.com/rebcabin/37f800da658f4b23ceaa >=20 > #+TITLE: Org-Babel Bug? > #+AUTHOR: Brian Beckman > #+EMAIL: bc.beckman@gmail.com >=20 > #+BEGIN_SRC emacs-lisp :exports results :results none > (setq org-confirm-babel-evaluate nil) > (org-babel-map-src-blocks nil (org-babel-remove-result)) > #+end_src >=20 > * Mystery Number 1 >=20 > The first line of the first block must be blank, or we must =3DC-c C-c=3D= the block > two times. But we want to eval the entire file /via/ =3DC-c C-v C-b=3D, a= nd we found > that the first line must be empty. >=20 > If you =3DC-c C-v C-b=3D this entire file, the python session buffer, nam= ed > =3D*bug-org-babel*=3D, contains an error message that suggests the variab= le =3D_=3D is > implicated in an error. >=20 > We expect the value of this first block to be 999. Make sure that the py= thon > session is clear by typing =3Dquit()=3D, then evaluate this entire file by > =3DC-c C-v C-b=3D. I=E2=80=99m not entirely sure what the error you are seeing is. I tried ru= nning the below src block both with and without the initial blank line. In both cases the result was 999, as expected, and no errors were reported in the session buffer. It would be good if you could use M-x org-version to report the exact version of org you are using. >=20 > #+NAME: probe > #+BEGIN_SRC python :session bug-org-babel :exports both :results value >=20 > 999 > #+END_SRC >=20 > #+RESULTS: probe > : 999 >=20 > * Mystery Number 2 >=20 > Now, we set the value of the variable =3D_=3D to something arbitray. In a= real > scenario, this variable may be set casually in a loop or some other conte= xt. The > variable =3D_=3D is often recommended for /ad-hoc/ use, as in "don't > care." In the python repl, _ is set to the result of the last statement. ob-python uses that fact to extract the value from the python process. I would expect that creating an overriding binding of _ would cause strange problems like the one you reported. So you should not assign to _ in babel code. --=20 Aaron Ecay