I'm using lstinputlisting to include code examples in my thesis, but as I'm working on the text and the code simultaneously, the code is not yet fixed in length. Is there any way that I can define a range of lines in my code dynamically so that the imported lines will be updated if I change the code (somehow as I'd do in iPython)?
At the moment I'm only using firstline= and lastline= as in this script example:
\lstinputlisting[language=Python, firstline=135, lastline=145]{code/inv1.py}
But when I add a line to my script, the range is out-of-phase with some funny results.
A dream scenario would be something like this pseudo code:
\lstinputlisting[language=Python, firstline=label{#loop2}, lastline=label{#end_loop2}]{code/inv1.py}
Can minted or another listing package be the solution? My code and scripts are in C# and Python.