>>> import re
>>> s="The Strings"
>>> s=re.sub("\w","#",s)
>>> s
'### #######'
>>> s='Hello' + "her mom's shirt"
>>> s
"Helloher mom's shirt"
>>> re.sub("\w","#",s)
"######## ###'# #####"
----Edit
OK, Now I understand that you want the output to be from a Python file. Try:
import fileinput
import re
for line in fileinput.input():
iter = re.finditer(r'(\'[^\']+\'|"[^"]+")',line)
for m in iter:
span = m.span()
paren = m.group()[0]
line = line[:span[0]]+paren+'#'*(span[1]-span[0]-2)+paren+line[span[1]:]
print line.rstrip()
This does not deal with line breaks, the """ form, and is only tested again 1 or two files I have...
In general, it is better to use a parser for this kind of job.
Best