From: Rainer M Krug <r.m.krug@gmail.com>
To: Dirk Scharff <dirk.scharff@googlemail.com>
Cc: Org mailing list <emacs-orgmode@gnu.org>
Subject: Re: Need control over insertion point of variables in code blocks
Date: Fri, 22 Jul 2011 09:34:03 +0200 [thread overview]
Message-ID: <CAGhLh6Hw7JU1+c4m3vPvMPvNYo8X_VwJkW3SdVTmRcjGf1bwYg@mail.gmail.com> (raw)
In-Reply-To: <A6014528-2B3B-4B8C-96D6-47BB46A3AB21@googlemail.com>
[-- Attachment #1: Type: text/plain, Size: 2017 bytes --]
On Fri, Jul 22, 2011 at 9:22 AM, Dirk Scharff
<dirk.scharff@googlemail.com>wrote:
> Hi
>
> i just noticed that variables are assigned in the top of the exported code.
> That can be problematic in some situations:
>
> #+source: the_test
> #+begin_src python :var x=3 :tangle test.py :results output
> from __future__ import division
> print x
> #+end_src
>
>
> tangling results in:
>
> x=3
> from __future__ import division
> print x
>
> The problem with the result is simple:
> SyntaxError: from __future__ imports must occur at the beginning of the
> file
>
> To export this correctly I'd need the possibility to tell org-mode where
> the variables are supposed to be inserted. Is there a way to do this? I
> didn't find a keyword for this in the documentation.
>
For tangling: you could put from __future__ imports into the :shebang and
use padline ":padline no", i.e.:
#+source: the_test
#+begin_src python :var x=3 :tangle test.py :results output :shebang from
__future__ imports :padline no
print x
#+end_src
which results in
from __future__ imports
print x
Keep in mind, that I have NEVER used python (although I should...).
Cheers,
Rainer
>
A second problem I have at the moment lies with the execution of
> source-blocks in tables. What I'd like to do:
>
> | argument | result |
> | 1 | #ERROR |
> | | |
> #+TBLFM: $2=call_the_test(x=$<)
>
> I guess I'm just doing something wrong here. Executing the #+Tblfm results
> in the error: "reference $< not found in buffer". How do I do the reference
> correctly in this case?
>
> You can test both cases in the attached org-file.
>
>
>
>
>
>
--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology,
UCT), Dipl. Phys. (Germany)
Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa
Tel : +33 - (0)9 53 10 27 44
Cell: +33 - (0)6 85 62 59 98
Fax (F): +33 - (0)9 58 10 27 44
Fax (D): +49 - (0)3 21 21 25 22 44
email: Rainer@krugs.de
Skype: RMkrug
[-- Attachment #2: Type: text/html, Size: 3000 bytes --]
next prev parent reply other threads:[~2011-07-22 7:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-22 7:22 Need control over insertion point of variables in code blocks Dirk Scharff
2011-07-22 7:34 ` Rainer M Krug [this message]
2011-07-22 7:55 ` Dirk Scharff
2011-07-22 8:02 ` Rainer M Krug
[not found] ` <87aac6u0rk.fsf@gnu.org>
2011-07-22 9:36 ` Dirk Scharff
2011-07-22 13:32 ` Bastien
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAGhLh6Hw7JU1+c4m3vPvMPvNYo8X_VwJkW3SdVTmRcjGf1bwYg@mail.gmail.com \
--to=r.m.krug@gmail.com \
--cc=dirk.scharff@googlemail.com \
--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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.