all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: Liu Hui <liuhui1610@gmail.com>, Jack Kamm <jackkamm@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] ob-python: support header argument `:results file graphics'
Date: Tue, 04 Jul 2023 11:29:20 +0000	[thread overview]
Message-ID: <877crfvrsf.fsf@localhost> (raw)
In-Reply-To: <CAOQTW-PHT1mFgUUbm8YcfqZ18Fnxq9MxUuGF66dthCyt79QFOQ@mail.gmail.com>

[ CCing ob-python maintainer. ]

Liu Hui <liuhui1610@gmail.com> writes:

>> May you elaborate?
>>
>> #+begin_src python :results file
>> implies that the result of execution is file _contents_.
>
> It is consistent with current behavior, e.g. `:results file' is used
> to produce graphics file
> https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-python.html

WORG documentation is not accurate here.

More precisely,

#+name: some-name
#+begin_src python :results file :file-ext txt

will interpret results as file contents of "some-name.txt".

If the block has :file parameter _or_ :file-exp parameter and #+name,
the results of evaluation are inserted into a file. Otherwise, results
of evaluation are interpreted as file name--*undocumented*.

That said, your patch should still work fine even with these
considerations. But we may need to sort out this undocumented behaviour.
Probably, an error like in `org-babel-graphical-output-file' should be
thrown by `org-babel-generate-file-param'.

> Any src blocks worked in the past still work with this patch, without
> any adjustments. The patch only makes the following src block, which
> cannot produce `test.png' in the past, can produce `test.png'.
>
> #+begin_src python :file "test.png" :results graphics file
> import matplotlib.pyplot as plt
> plt.plot([1,2,3,4,5])
> #+end_src

Right.

What about

#+begin_src python :file "test.png" :results graphics file
import matplotlib.pyplot as plt
plt.plot([1,2,3,4,5])
plt.savefig('test.png')
plt.plot([5,4,3,2,1])
plt.show()
#+end_src

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


  reply	other threads:[~2023-07-04 11:30 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-03  4:31 [PATCH] ob-python: support header argument `:results file graphics' Liu Hui
2023-07-03  9:28 ` Ihor Radchenko
2023-07-03 10:40   ` Liu Hui
2023-07-03 11:41     ` Ihor Radchenko
2023-07-03 13:23       ` Liu Hui
2023-07-04 11:29         ` Ihor Radchenko [this message]
2023-07-05  5:23           ` Jack Kamm
2023-07-05 11:05             ` Ihor Radchenko
2023-07-06  2:49               ` Jack Kamm
2023-07-07 10:53                 ` Ihor Radchenko
2023-07-08 13:55                   ` Jack Kamm
2023-07-09  9:12                     ` Ihor Radchenko
2023-07-12  5:10                       ` Jack Kamm
2023-07-12  8:38                         ` Ihor Radchenko
2023-07-14  2:47                           ` Jack Kamm
2023-07-05  8:09           ` Liu Hui
2023-07-05  4:55   ` Jack Kamm
2023-07-07 10:56     ` Ihor Radchenko
2023-07-05  5:13 ` Jack Kamm
2023-07-05  8:11   ` Liu Hui
2023-07-06  3:49     ` Jack Kamm
2023-07-06  9:54       ` Liu Hui
2023-07-08 13:59         ` Jack Kamm

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=877crfvrsf.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=jackkamm@gmail.com \
    --cc=liuhui1610@gmail.com \
    /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.