> When printing a list, the individual elements are converted with repr(),
> not with str(). For a string object, repr() adds escape codes for all
> bytes that are not printable ASCII characters.
Thanks Martin, you're right, it were the repr() calls that messed up the
output. Iterating the array
Rehceb Rotkiv schrieb:
> Hello,
>
> I have this little grep-like program:
>
> ++snip++
> #!/usr/bin/python
>
> import sys
> import re
>
> pattern = sys.argv[1]
> inputfile = file(sys.argv[2], 'r')
>
> for line in inputfile:
> matches = re.findall(pattern, line)
> if mat
> Like this, the program prints some characters as strange escape
> sequences, which is due to the input file being encoded in utf-8: When I
> convert "re.findall..." to a string and wrap an "unicode()" around it,
> the matches get printed correctly. Is it possible to make "matches"
> unicode w
Rehceb Rotkiv wrote:
> Hello,
>
> I have this little grep-like program:
>
> ++snip++
> #!/usr/bin/python
>
> import sys
> import re
>
> pattern = sys.argv[1]
> inputfile = file(sys.argv[2], 'r')
>
> for line in inputfile:
> matches = re.findall(pattern, line)
> if matches:
>
Hello,
I have this little grep-like program:
++snip++
#!/usr/bin/python
import sys
import re
pattern = sys.argv[1]
inputfile = file(sys.argv[2], 'r')
for line in inputfile:
matches = re.findall(pattern, line)
if matches:
print matches
++snip++
L