The code 

for text in open("file.txt","r"):
    print text.replace("foo","bar")[:-1]

replaces 'foo' with 'bar' in a file, but how do I avoid changing text
inside single or double quotes? For making changes to Python code, I
would also like to avoid changing text in comments, either the '#' or
'""" ... """' kind.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to