From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dirk Scharff Subject: Re: Need control over insertion point of variables in code blocks Date: Fri, 22 Jul 2011 09:55:28 +0200 Message-ID: References: Mime-Version: 1.0 (Apple Message framework v1244.3) Content-Type: multipart/alternative; boundary="Apple-Mail=_CCAB8243-9417-4FE4-936D-10DD2A952E26" Return-path: Received: from eggs.gnu.org ([140.186.70.92]:54937) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QkAa6-0001yO-UT for emacs-orgmode@gnu.org; Fri, 22 Jul 2011 03:55:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QkAa5-0000tZ-MR for emacs-orgmode@gnu.org; Fri, 22 Jul 2011 03:55:34 -0400 Received: from mail-fx0-f52.google.com ([209.85.161.52]:64769) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QkAa5-0000tP-EN for emacs-orgmode@gnu.org; Fri, 22 Jul 2011 03:55:33 -0400 Received: by fxd18 with SMTP id 18so3936470fxd.39 for ; Fri, 22 Jul 2011 00:55:32 -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: Rainer M Krug Cc: Org mailing list --Apple-Mail=_CCAB8243-9417-4FE4-936D-10DD2A952E26 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=windows-1252 Hi Am 22.07.2011 um 09:34 schrieb Rainer M Krug: > For tangling: you could put from __future__ imports into the = :shebang and use padline ":padline no", i.e.: >=20 > #+source: the_test > #+begin_src python :var x=3D3 :tangle test.py :results output :shebang = from __future__ imports :padline no > print x > #+end_src >=20 > which results in >=20 > from __future__ imports > print x >=20 > Keep in mind, that I have NEVER used python (although I should=85). While I'd not call that a clean solution to the problem it will keep me = going for now.=20 Thank you very much for pointing that possibility out, I haven't thought = about trying to move the import statement.=20 As for python: its a nice language worth trying in my opinion ;) =20 With this i could do the table calculation manually by inserting = 100-1000 call statements (in the real use case I need for my = masters-thesis) but it would be really nice if i could use a table cell = as argument for code-blocks.=20 > A second problem I have at the moment lies with the execution of = source-blocks in tables. What I'd like to do: >=20 > | argument | result | > | 1 | #ERROR | > | | | > #+TBLFM: $2=3Dcall_the_test(x=3D$<) >=20 > 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? >=20 > You can test both cases in the attached org-file. best regards, Dirk= --Apple-Mail=_CCAB8243-9417-4FE4-936D-10DD2A952E26 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=windows-1252
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=3D3 :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=85).

While I'd not call = that a clean solution to the problem it will keep me going for = now. 

Thank you very much for pointing = that possibility out, I haven't thought about trying to move the import = statement. 

As for python: its a nice = language worth trying in my opinion ;) =  


With this i could do the = table calculation manually by inserting 100-1000 call statements (in the = real use case I need for my masters-thesis) but it would be really nice = if i could use a table cell as argument for = code-blocks. 

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=3Dcall_the_test(x=3D$<)

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.


best regards,
Dirk
= --Apple-Mail=_CCAB8243-9417-4FE4-936D-10DD2A952E26--