# script_from_examples.py
""" Script to convert python interpreter examples into python code
Usage:
python script_from_examples.py <file>
read a file containing python interpreter examples and outputs
the python code without the prompt. For example if <file> contains
>>> L = range(3)
>>> for x in L:
... print x
...
0
1
2
>>>
the output of the command in stdout will be the python code
L = range(3)
for x in L:
print x
# Expected:
## 0
## 1
## 2
"""
import doctest
import sys
if __name__ == "__main__":
assert len(sys.argv) == 2
filename = sys.argv[-1]
print doctest.script_from_examples(open(filename).read())