From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christopher Allan Webber Subject: Re: Org-babel `:hlines yes` no longer working for python Date: Sat, 26 Jun 2010 15:12:35 -0500 Message-ID: <87d3vd1rkc.fsf@dustycloud.org> References: <87k4pl27vv.fsf@dustycloud.org> <87bpaxbu2w.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from [140.186.70.92] (port=33825 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OSbjn-0001Ao-87 for emacs-orgmode@gnu.org; Sat, 26 Jun 2010 16:12:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OSbjl-0006dS-7w for emacs-orgmode@gnu.org; Sat, 26 Jun 2010 16:12:27 -0400 Received: from li28-75.members.linode.com ([75.127.72.75]:40667) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OSbjl-0006d9-4m for emacs-orgmode@gnu.org; Sat, 26 Jun 2010 16:12:25 -0400 In-Reply-To: <87bpaxbu2w.fsf@gmail.com> (Eric Schulte's message of "Sat, 26 Jun 2010 10:08:07 -0700") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Eric Schulte Cc: emacs-orgmode@gnu.org Hey Eric, Thanks for the super helpful reply! Out of curiosity, is it likely that we will ever get hline support in Python and etc? I've been pondering how it might be done, and maybe it could be like this, using a '|-' string instead of a list for the row: [['a', 'b', 'c'], '|-', ['d', 'e', 'f'], ['g', 'h', 'i']] Which would produce: | a | b | c | |---+---+---| | d | e | f | | g | h | i | Alternately maybe the same thing could be done by abusing None: [['a', 'b', 'c'], None, ['d', 'e', 'f'], ['g', 'h', 'i']] Thoughts? - cwebb "Eric Schulte" writes: > Hi Christopher, > > Thanks for pointing this out, this is an error in the documentation, > which I will update. The code you posted should generate the error you > have received. > > Currently the only language which can handle hlines is emacs-lisp, all > other languages will result in errors like the one you pasted below. > That's not to say that it wouldn't be possible to add hline handling to > other languages, or to maybe do something tricky like session-based > evaluation in which an `hlines' variable was pre-initialized to some > value, but I digress. > > Note that it *is* possible to have hlines in the output, using colnames, > e.g. > > > --8<---------------cut here---------------start------------->8--- > #+tblname: A > | a | b | c | > |---+---+---| > | d | e | f | > | g | h | i | > > #+begin_src python :var tab=A :colnames yes > return [[val + '*' for val in row] for row in tab] > #+end_src > > #+results: > | a | b | c | > |----+----+----| > | d* | e* | f* | > | g* | h* | i* | > --8<---------------cut here---------------end--------------->8--- > > which works because the hline, and the column names, are never made > available to python, rather Babel holds onto them and then re-applies > them to the source block's output. > > or even to have an elisp block add hlines to your results > > > --8<---------------cut here---------------start------------->8--- > #+tblname: many-cols > | a | b | c | > |---+---+---| > | d | e | f | > |---+---+---| > | g | h | i | > > #+source: echo-table > #+begin_src python :var tab=many-cols > return tab > #+end_src > > #+begin_src emacs-lisp :var table=echo-table > (butlast (apply #'append (mapcar (lambda (el) (list el 'hline)) table))) > #+end_src > > #+results: > | a | b | c | > |---+---+---| > | d | e | f | > |---+---+---| > | g | h | i | > --8<---------------cut here---------------end--------------->8--- > > Thanks for pointing this out! > > Best -- Eric > > Christopher Allan Webber writes: > >> Hello all, >> >> I was going through the tutorial and testing the :hlines yes feature as >> described in the info manual. Unfortunately, the example given no >> longer seems to work for python: >> >> #+tblname: many-cols >> | a | b | c | >> |---+---+---| >> | d | e | f | >> |---+---+---| >> | g | h | i | >> >> #+source: echo-table >> #+begin_src python :var tab=many-cols :hlines yes >> return tab >> #+end_src >> >> #+results: echo-table >> | a | b | c | >> | d | e | f | >> | g | h | i | >> >> In the buffer *Org-Babel Error Output* I see: >> >> Traceback (most recent call last): >> File "", line 6, in >> File "", line 3, in main >> NameError: global name 'hline' is not defined >> >> In emacs-lisp this still seems to work though. But I also see that in >> emacs lisp hlines are represented by the hline symbol. I'm guessing >> that the python equivalent was trying to do the same thing, but no hline >> variable exists in python? >> >> Thanks! >> - cwebb >> >> _______________________________________________ >> Emacs-orgmode mailing list >> Please use `Reply All' to send replies to the list. >> Emacs-orgmode@gnu.org >> http://lists.gnu.org/mailman/listinfo/emacs-orgmode