itβs very rude to crack this job:
use your favorite text editor, use the search / search function.
find all print statements. A.
and enter the number or identifier manually in each of them. (or automatically if you do that script)
a script to do this would be simple, just try print with a regular expression and replace it with print ID, , and then everything will be the same, but you will get the numbers.
greetings.
change
Forbid any weird formatting, the following code should do it for you.
Notice this is just an example of how you could do this. not really an answer.
import re class inc(): def __init__(self): self.x = 0 def get(self): self.x += 1 return self.x def replacer(filename_in, filename_out): i = inc() out = open(filename_out, 'w') with open(filename_in) as f: for line in f: out.write("%s\n" % re.sub(r'print', 'print %d,' % i.get(), line))
I used the base class incrementer if you wanted to have some kind of more complex identifier, and not just have a counter.
source share