I have python code like that has this kind of structure
def main:
''' comment '''
if True:
print "do"
print "done
This code is not compatible with the interactive-mode (for example if I copy/paste it in an interactive session). For this it would need to be :
def main:
''' comment '''
if True:
print "do"
print "done"
otherwise the interactive mode breaks on Indentation problems.
Do you know a simple way to transform the code with the generate_token / untokenize chain ? I am a bit lost in the NL / NEWLINE / INDENT / DEDENT semantics.
I found this Script to remove Python comments/docstrings that removes comments/docstrings. It looks like a perfect fit for my problem but it cannot sort it out to have a clean output on complex code.
the best I could come up with (resolved my issue)