1

I have been trying to find a way to convert my python file to pdf. I found latex, pyweave and others but I am unable to understand on how not to include input code in my pdf. Also, how to use pyweave? My pdf should not contain any code, just the ouputs. How do i achieve it?

In jupyter we've nbconvert tool with --no input flag. How about in regular python file?

rojoka
  • 77
  • 7

2 Answers2

0

The python package might be helpful:

\documentclass{article}

\usepackage{python}

\begin{document}

\begin{python}
print("42")
\end{python}

\end{document}

(needs to be compiled with shell-escape enabled)

0

One of the ways possible: https://discourse.mcneel.com/t/saving-the-python-output-as-textfile/14987/2 referring to the above post

1. Create an empty python string

output_string = ''

2. Start adding all the possible outcomes into output_string

# If you want perform print(some_object), add it to the string
output_string = output_string + str(some_object) + "\n"

3. Convert string into a pdf file using any technique

TheSHETTY-Paradise
  • 1,024
  • 2
  • 9
  • 19