From mboxrd@z Thu Jan 1 00:00:00 1970 From: Emmanuel Charpentier Subject: Re: (9.2) Noweb blocks not expanded in Python blocks : it should be a bug... Date: Mon, 04 Feb 2019 14:40:04 +0100 Message-ID: References: <0d423cc9589a5b74bbdbbc9a63501ae8d5325a24.camel@free.fr> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="=-JheswBTlQRBTFLJeZlvl" Return-path: Received: from eggs.gnu.org ([209.51.188.92]:57427) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqeTs-0007Ur-P2 for emacs-orgmode@gnu.org; Mon, 04 Feb 2019 08:40:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gqeTq-0004jM-CX for emacs-orgmode@gnu.org; Mon, 04 Feb 2019 08:40:12 -0500 Received: from smtp1-g21.free.fr ([2a01:e0c:1:1599::10]:54722) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gqeTq-0004d2-0Z for emacs-orgmode@gnu.org; Mon, 04 Feb 2019 08:40:10 -0500 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" To: John Kitchin Cc: org-mode-email --=-JheswBTlQRBTFLJeZlvl Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Le lundi 04 f=C3=A9vrier 2019 =C3=A0 08:11 -0500, John Kitchin a =C3=A9cr= it : > The problem may be the name is only two characters long. Try Ahh > instead. That works for me.=20 Indeed. Nice catch ; how did you find this ? Since this doesn't happen with emacs-lisp or Sage, and since nothing in the docs I've read so far suggests anything about the length of a block identifier, I consider this a bug in the Python language support code. What do you think ? Any hint ? Thanks a lot ! --Emmanuel Charpentier > John >=20 > ----------------------------------- > Professor John Kitchin=20 > Doherty Hall A207F > Department of Chemical Engineering > Carnegie Mellon University > Pittsburgh, PA 15213 > 412-268-7803 > @johnkitchin > http://kitchingroup.cheme.cmu.edu >=20 >=20 >=20 > On Mon, Feb 4, 2019 at 7:00 AM Emmanuel Charpentier < > emm.charpentier@free.fr> wrote: > > Seen in `org-mode' version `9.2'. > >=20 > >=20 > >=20 > > Using `noweb' syntax works OK with `emacs-lisp': > >=20 > >=20 > >=20 > > =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > >=20 > > =E2=94=82 #+name: a > >=20 > > =E2=94=82 #+begin_src emacs-lisp > >=20 > > =E2=94=82 (setq L (append L (list i))) > >=20 > > =E2=94=82 #+end_src > >=20 > > =E2=94=82=20 > >=20 > > =E2=94=82 #+name: b > >=20 > > =E2=94=82 #+begin_src emacs-lisp :noweb yes :exports both > >=20 > > =E2=94=82 ;; Lisp version > >=20 > > =E2=94=82 (setq L nil) > >=20 > > =E2=94=82 (dotimes (i 5) <>) > >=20 > > =E2=94=82 L > >=20 > > =E2=94=82 #+end_src > >=20 > > =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > >=20 > >=20 > >=20 > > This gives : > >=20 > >=20 > >=20 > > =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > >=20 > > =E2=94=82 (setq L (append L (list i))) > >=20 > > =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > >=20 > >=20 > >=20 > > =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > >=20 > > =E2=94=82 ;; Lisp version > >=20 > > =E2=94=82 (setq L nil) > >=20 > > =E2=94=82 (dotimes (i 5) ) > >=20 > > =E2=94=82 L > >=20 > > =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > >=20 > >=20 > >=20 > > The `noweb' syntax also works with `Sage' (a symbolic maths > > oriented > >=20 > > Python derivative): > >=20 > >=20 > >=20 > > =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > >=20 > > =E2=94=82 #+name: Aaarghhh > >=20 > > =E2=94=82 #+begin_src sage > >=20 > > =E2=94=82 L.append(i) > >=20 > > =E2=94=82 #+end_src > >=20 > > =E2=94=82=20 > >=20 > > =E2=94=82 #+name: Berde > >=20 > > =E2=94=82 #+begin_src sage :noweb yes :exports both > >=20 > > =E2=94=82 ## Python version > >=20 > > =E2=94=82 L=3D[] > >=20 > > =E2=94=82 for i in range(1,6): > >=20 > > =E2=94=82 <> > >=20 > > =E2=94=82 L > >=20 > > =E2=94=82 #+end_src > >=20 > > =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > >=20 > >=20 > >=20 > > wich gives : > >=20 > >=20 > >=20 > > =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > >=20 > > =E2=94=82 L.append(i) > >=20 > > =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > >=20 > >=20 > >=20 > > =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > >=20 > > =E2=94=82 ## Sage version > >=20 > > =E2=94=82 L=3D[] > >=20 > > =E2=94=82 for i in range(1,6): > >=20 > > =E2=94=82=20 > >=20 > > =E2=94=82 L > >=20 > > =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > >=20 > >=20 > >=20 > > But using the same syntax in Python fails miserably: > >=20 > >=20 > >=20 > > =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > >=20 > > =E2=94=82 #+name: Ah > >=20 > > =E2=94=82 #+begin_src python > >=20 > > =E2=94=82 L.append(i) > >=20 > > =E2=94=82 #+end_src > >=20 > > =E2=94=82=20 > >=20 > > =E2=94=82 #+name: Beee > >=20 > > =E2=94=82 #+begin_src python :noweb yes :exports both > >=20 > > =E2=94=82 ## Python version > >=20 > > =E2=94=82 L=3D[] > >=20 > > =E2=94=82 for i in range(1,6): > >=20 > > =E2=94=82 <> > >=20 > > =E2=94=82 L > >=20 > > =E2=94=82 #+end_src > >=20 > > =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > >=20 > >=20 > >=20 > > =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > >=20 > > =E2=94=82 L.append(i) > >=20 > > =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > >=20 > >=20 > >=20 > > =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > >=20 > > =E2=94=82 ## Python version > >=20 > > =E2=94=82 L=3D[] > >=20 > > =E2=94=82 for i in range(1,6): > >=20 > > =E2=94=82 <> > >=20 > > =E2=94=82 L > >=20 > > =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > >=20 > >=20 > >=20 > > =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > >=20 > > =E2=94=82 [] > >=20 > > =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > >=20 > >=20 > >=20 > >=20 > >=20 > > It *seems* that the "Ah" block is not expanded. > >=20 > >=20 > >=20 > > The code itself should be sound *if* it expanded: > >=20 > >=20 > >=20 > > =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > >=20 > > =E2=94=82 #+name: B0 > >=20 > > =E2=94=82 #+begin_src python :exports both > >=20 > > =E2=94=82 L=3D[] > >=20 > > =E2=94=82 for i in range(1,6): > >=20 > > =E2=94=82 L.append(i) > >=20 > > =E2=94=82 L > >=20 > > =E2=94=82 #+end_src > >=20 > > =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > >=20 > >=20 > >=20 > > =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > >=20 > > =E2=94=82 L=3D[] > >=20 > > =E2=94=82 for i in range(1,6): > >=20 > > =E2=94=82 L.append(i) > >=20 > > =E2=94=82 L > >=20 > > =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > >=20 > >=20 > >=20 > > =E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94= =81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81 > >=20 > > 1 2 3 4 5=20 > >=20 > > =E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94= =81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81 > >=20 > >=20 > >=20 > > During the compilation of the source of this mail, the following is > >=20 > > printed in the `*Python*' buffer: > >=20 > >=20 > >=20 > > =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > >=20 > > =E2=94=82 >>> L.append(i) > >=20 > > =E2=94=82 >>>=20 > >=20 > > =E2=94=82 >>> open('/tmp/babel-OJSsxf/python-dVESY4', 'w').write(str(= _)) > >=20 > > =E2=94=82 >>>=20 > >=20 > > =E2=94=82 >>>=20 > >=20 > > =E2=94=82 >>> 'org_babel_python_eoe' > >=20 > > =E2=94=82 'org_babel_python_eoe' > >=20 > > =E2=94=82 >>> ## Python version > >=20 > > =E2=94=82 ... L=3D[] > >=20 > > =E2=94=82 >>> for i in range(1,6): > >=20 > > =E2=94=82 ... <> > >=20 > > =E2=94=82 File "", line 2 > >=20 > > =E2=94=82 <> > >=20 > > =E2=94=82 ^ > >=20 > > =E2=94=82 SyntaxError: invalid syntax > >=20 > > =E2=94=82 >>>=20 > >=20 > > =E2=94=82 >>> L > >=20 > > =E2=94=82 [] > >=20 > > =E2=94=82 >>>=20 > >=20 > > =E2=94=82 >>> open('/tmp/babel-OJSsxf/python-9NR46u', 'w').write(str(= _)) > >=20 > > =E2=94=82 >>>=20 > >=20 > > =E2=94=82 >>>=20 > >=20 > > =E2=94=82 >>> 'org_babel_python_eoe' > >=20 > > =E2=94=82 'org_babel_python_eoe' > >=20 > > =E2=94=82 >>> L=3D[] > >=20 > > =E2=94=82 >>> for i in range(1,6): > >=20 > > =E2=94=82 ... L.append(i) > >=20 > > =E2=94=82 ...=20 > >=20 > > =E2=94=82 >>> L > >=20 > > =E2=94=82 [1, 2, 3, 4, 5] > >=20 > > =E2=94=82 >>>=20 > >=20 > > =E2=94=82 >>> open('/tmp/babel-OJSsxf/python-fW5gK0', 'w').write(str(= _)) > >=20 > > =E2=94=82 >>>=20 > >=20 > > =E2=94=82 >>>=20 > >=20 > > =E2=94=82 >>> 'org_babel_python_eoe' > >=20 > > =E2=94=82 'org_babel_python_eoe' > >=20 > > =E2=94=82 >>>=20 > >=20 > > =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > >=20 > >=20 > >=20 > > The source code of this mail is attached. > >=20 > >=20 > >=20 > > -- > >=20 > > Emmanuel Charpentier > >=20 --=-JheswBTlQRBTFLJeZlvl Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable
Le lundi 04 f=C3=A9vrier 2019 =C3=A0 08:11 -0500, John Kitchin a = =C3=A9crit :
The prob= lem may be the name is only two characters long. Try Ahh instead. That work= s for me. 

Ind= eed. Nice catch ; how did you find this ?

Since th= is doesn't happen with emacs-lisp or Sage, and since nothing in the docs I'= ve read so far suggests anything about the length of a block identifier, I = consider this a bug in the Python language support code. What do you think = ? Any hint ?

Thanks a lot !

<= div>--
Emmanuel Charpentier


On Mon, Feb 4, 2019 at 7:00 AM Emmanuel Charpentier <<= a href=3D"mailto:emm.charpentier@free.fr">emm.charpentier@free.fr> w= rote:
Seen in `org-mode' version `9.2'.=

Using `noweb' syntax works OK with `emacs-lisp':

=E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80
=E2=94=82 #+name: a
=E2=94=82 #+begin_src emacs-lisp
=E2=94=82   (setq L (append L (list i)))
=E2=94=82 #+end_src
=E2=94=82
=E2=94=82 #+name: b
=E2=94=82 #+begin_src emacs-lisp :noweb yes :exports both
=E2=94=82   ;; Lisp version
=E2=94=82   (setq L nil)
=E2=94=82   (dotimes (i 5) <<a>>)
=E2=94=82   L
=E2=94=82 #+end_src
=E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80

This gives :

=E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80
=E2=94=82 (setq L (append L (list i)))
=E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80

=E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80
=E2=94=82 ;; Lisp version
=E2=94=82 (setq L nil)
=E2=94=82 (dotimes (i 5) )
=E2=94=82 L
=E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80

The `noweb' syntax also works with `Sage' (a symbolic maths oriented
Python derivative):

=E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80
=E2=94=82 #+name: Aaarghhh
=E2=94=82 #+begin_src sage
=E2=94=82   L.append(i)
=E2=94=82 #+end_src
=E2=94=82
=E2=94=82 #+name: Berde
=E2=94=82 #+begin_src sage :noweb yes :exports both
=E2=94=82   ## Python version
=E2=94=82   L=3D[]
=E2=94=82   for i in range(1,6):
=E2=94=82       <<Aaarghhh>>
=E2=94=82   L
=E2=94=82 #+end_src
=E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80

wich gives :

=E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80
=E2=94=82 L.append(i)
=E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80

=E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80
=E2=94=82 ## Sage version
=E2=94=82 L=3D[]
=E2=94=82 for i in range(1,6):
=E2=94=82
=E2=94=82 L
=E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80

But using the same syntax in Python fails miserably:

=E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80
=E2=94=82 #+name: Ah
=E2=94=82 #+begin_src python
=E2=94=82   L.append(i)
=E2=94=82 #+end_src
=E2=94=82
=E2=94=82 #+name: Beee
=E2=94=82 #+begin_src python :noweb yes :exports both
=E2=94=82   ## Python version
=E2=94=82   L=3D[]
=E2=94=82   for i in range(1,6):
=E2=94=82       <<Ah>>
=E2=94=82   L
=E2=94=82 #+end_src
=E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80

=E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80
=E2=94=82 L.append(i)
=E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80

=E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80
=E2=94=82 ## Python version
=E2=94=82 L=3D[]
=E2=94=82 for i in range(1,6):
=E2=94=82     <<Ah>>
=E2=94=82 L
=E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80

=E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80
=E2=94=82 []
=E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80


It *seems* that the "Ah" block is not expanded.

The code itself should be sound *if* it expanded:

=E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80
=E2=94=82 #+name: B0
=E2=94=82 #+begin_src python :exports both
=E2=94=82   L=3D[]
=E2=94=82   for i in range(1,6):
=E2=94=82       L.append(i)
=E2=94=82   L
=E2=94=82 #+end_src
=E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80

=E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80
=E2=94=82 L=3D[]
=E2=94=82 for i in range(1,6):
=E2=94=82     L.append(i)
=E2=94=82 L
=E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80

=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2= =94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81
 1  2  3  4  5
=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2= =94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81=E2=94=81

During the compilation of the source of this mail, the following is
printed in the `*Python*' buffer:

=E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80
=E2=94=82 >>> L.append(i)
=E2=94=82 >>>
=E2=94=82 >>> open('/tmp/babel-OJSsxf/python-dVESY4', 'w').write(s= tr(_))
=E2=94=82 >>>
=E2=94=82 >>>
=E2=94=82 >>> 'org_babel_python_eoe'
=E2=94=82 'org_babel_python_eoe'
=E2=94=82 >>> ## Python version
=E2=94=82 ... L=3D[]
=E2=94=82 >>> for i in range(1,6):
=E2=94=82 ...     <<Ah>>
=E2=94=82   File "<stdin>", line 2
=E2=94=82     <<Ah>>
=E2=94=82      ^
=E2=94=82 SyntaxError: invalid syntax
=E2=94=82 >>>
=E2=94=82 >>> L
=E2=94=82 []
=E2=94=82 >>>
=E2=94=82 >>> open('/tmp/babel-OJSsxf/python-9NR46u', 'w').write(s= tr(_))
=E2=94=82 >>>
=E2=94=82 >>>
=E2=94=82 >>> 'org_babel_python_eoe'
=E2=94=82 'org_babel_python_eoe'
=E2=94=82 >>> L=3D[]
=E2=94=82 >>> for i in range(1,6):
=E2=94=82 ...     L.append(i)
=E2=94=82 ...
=E2=94=82 >>> L
=E2=94=82 [1, 2, 3, 4, 5]
=E2=94=82 >>>
=E2=94=82 >>> open('/tmp/babel-OJSsxf/python-fW5gK0', 'w').write(s= tr(_))
=E2=94=82 >>>
=E2=94=82 >>>
=E2=94=82 >>> 'org_babel_python_eoe'
=E2=94=82 'org_babel_python_eoe'
=E2=94=82 >>>
=E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80

The source code of this mail is attached.

--
Emmanuel Charpentier
--=-JheswBTlQRBTFLJeZlvl--