emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ob-python.el: questions about output


From: Fraga, Eric
Subject: Re: ob-python.el: questions about output
Date: Mon, 24 Feb 2020 13:42:08 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

On Monday, 24 Feb 2020 at 02:13, R C wrote:
> When exported I would like the line: return 'img/ex1.png' not to be
> included in the listing of the src block.

I don't think this is currently possible in the sense you want.

You could use :noweb where you have one src block referring to others
and only output the code for the main body.  E.g. something along the
lines of

#+name: mainblock
#+begin_src python :results file :noweb yes
def f(x): return np.polyval(a, x)
a = [1, -4, 4.5, -1.5]
x = np.roots(a)
print(f'Roots of the polynomial are {x}')
x_ = np.linspace(np.min(x), np.max(x), 100)
#+end_src

#+name: full
#+begin_src python :results file :noweb yes
import numpy as np
import matplotlib.pyplot as plt
<<mainblock>>
plt.plot(x_, f(x_))
plt.plot(x, f(x), marker='o')
plt.savefig('img/ex1.png')
return 'img/ex1.png'
#+end_src

Longer term, better would be an implementation of :prologue and
:epilogue options for python src blocks like we have for Maxima.  It
would probably make sense to provide these options for most if not all
src blocks?

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.3.6-354-g9d5880



reply via email to

[Prev in Thread] Current Thread [Next in Thread]