I'm struggling to find a way to get SageTex and any of the commenting (comment or verbatim) packages to play nicely together. I'd like to be able to comment out a section of LaTeX code, containing SageTeX commands, so that nothing prints, but the Sage Code is run (but not printed) internally anyway.
Minimal Example:
\documentclass[12pt]{exam}
\usepackage{sagetex,comment}
\begin{document}
I'd like the Sage Code in the following \LaTeX to be run:
\begin{comment}
\begin{sagesilent}
foo=1
\end{sagesilent}
$\sage{2+2}$
\end{comment}
So that here I get a 1: $\sage{foo}$.
\end{document}
Note that moving the sagesilent outside the comment block is not an acceptable solution for the following reason:
I'm working on a homework document with a several other colleagues, some without access to a sage server. Problems contain both sagesilent and regular \sage{} environments (which could not be moved outside for typographical reasons). My colleagues are happy to download the sout file after all final Sage changes have been made, but they would like to be able to print a select subset of the questions themselves as we go through problems at different paces. Regular (%%) commenting out of the problem, without rerunning the resulting sage documents, just results in the sage results within the document getting scrambled (since SageTex seems to give variables its own numbers, and removing a variable just causes the output for that variable to shift to the next variable in the document.)
One hint: I'm perhaps naively hopeful that this is possible, since the exam class itself plays quite nicely with SageTex. In particular, whether or not solutions are set to print in an exam file, the same sout file works.