lstlisting looks working great on python scripts except for some signs. From my experience the symbols "-" and "*" are replaced with something else, very similar in shape, but different. As a result the script reported into the pdf file doesn't work. That's the problem we are dealing with.
Here a simple sample code we gonna use in order to deal with this issue:
\documentclass{article}
\usepackage{listings}
\begin{document}
\lstset{language=Python}
\lstset{frame=lines}
\lstset{caption={Insert code directly in your document}}
\lstset{label={lst:code_direct}}
\lstset{basicstyle=\footnotesize}
%\lstset{keepspaces=true}
\lstset{columns=fullflexible}
\begin{lstlisting}
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(-3, 3, 0.01)
y = np.sin(np.pi*x)/(np.pi*x)
plt.plot(x, y)
\end{lstlisting}
\end{document}
When I run it a pdf file is generated which looks great
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(−3, 3, 0.01)
y = np.sin(np.pi∗x)/(np.pi∗x)
plt.plot(x, y)
However, if I try to copy and paste this code on a Python intepreter I realize it does not work, as "*" and "-" are replaced with something else, very similar in shape, but different. Could you help me to fix it, please?