My question is directly related to this one.
Does there exists a solution for pythontex ? At least for the verbatim environment. More precisely, let us consider the following MWE :
\documentclass[a4paper]{book}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\usepackage{pythontex}
\newboolean{gap}
\setboolean{gap}{false}
%%%%%%%%%%%%
\begin{document}
\begin{pyverbatim} #or pyblock etc.
\hide{x=1}
y=2
\end{pyverbatim}
\end{document}
I would like that x=1 appears if and only if gap is true.