From: Emmanuel Charpentier <emm.charpentier@free.fr>
To: org-mode-email <emacs-orgmode@gnu.org>
Subject: Possible proble with Python block edition, or pilot error ?
Date: Tue, 05 Mar 2019 23:18:40 +0100 [thread overview]
Message-ID: <4fe8cca2b504c8d6154a49ace63fabb5e8601def.camel@free.fr> (raw)
The following python snippet does execute normally from a Python (2.7)
temporary buffer
Source : =========================================
print "Start of block called from a Python temporary buffer"
print NomDeFichier
try:
FN=NomDeFichier
except:
FN="Chose.txt"
finally:
print FN
print "**"+FN+"**"
print "End of block called from a Python temporary buffer"
=========================================
Execution result: =========================================
>>> Start of block called from a Python temporary buffer
Bidule.txt
Bidule.txt
**Bidule.txt**
End of block called from a Python temporary buffer
>>> Start of block called from a Python temporary buffer
Bidule.txt
Bidule.txt
**Bidule.txt**
End of block called from a Python temporary buffer
=========================================
But the following Babel Python block, from which the previous snippet
derives, fails to run :
Block : =========================================
#+begin_src python :var NomDeFichier="Bidule.txt" :exports both
:results file :preamble "# -*- coding: utf-8 -*-"
print "Start of block called from an Org Python block"
print NomDeFichier
try:
FN=NomDeFichier
except:
FN="Chose.txt"
finally:
print FN
# Irrelevant for now:
# F1=file(FN,"w")
# F1.write("Tagada\n")
# F1.write("tsoin-tsoin...\n")
# F1.close()
print "End of block called from an Org Python block"
# Kept to pacify Org...
FN
#+end_src
=========================================
Execution result : =========================================
>>> print "Start of block called from an Org Python block"
Start of block called from an Org Python block
>>> print NomDeFichier
Bidule.txt
>>> try:
... FN=NomDeFichier
...
File "<stdin>", line 3
^
SyntaxError: invalid syntax
>>> except:
File "<stdin>", line 1
except:
^
SyntaxError: invalid syntax
>>> FN="Chose.txt"
File "<stdin>", line 1
FN="Chose.txt"
^
IndentationError: unexpected indent
>>>
>>> finally:
File "<stdin>", line 1
finally:
^
SyntaxError: invalid syntax
>>> print FN
File "<stdin>", line 1
print FN
^
IndentationError: unexpected indent
>>>
>>> # Irrelevant for now:
... # F1=file(FN,"w")
... # F1.write("Tagada\n")
... # F1.write("tsoin-tsoin...\n")
... # F1.close()
... print "End of block called from an Org Python block"
End of block called from an Org Python block
>>> # Kept to pacify Org...
... FN
'Bidule.txt'
>>>
>>> open('/tmp/babel-2gEcoQ/python-r1nkjR', 'w').write(str(_))
>>>
>>>
>>> 'org_babel_python_eoe'
'org_babel_python_eoe'
>>>
=========================================
Possibly relevant : from (packages-list-packages) :
python-mode 20181223.1933 installed Python major
mode
Also posibly relevant : a very similar Sage block, whose edit mode is
sage-shell-mode, runs without problem.
I'm lost. Suggestions ?
--
Emmanuel Charpentier
reply other threads:[~2019-03-05 22:19 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4fe8cca2b504c8d6154a49ace63fabb5e8601def.camel@free.fr \
--to=emm.charpentier@free.fr \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).