Re: Unicode list

2007-04-01 Thread Rehceb Rotkiv
> 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

Re: Unicode list

2007-04-01 Thread Georg Brandl
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

Re: Unicode list

2007-03-31 Thread Martin v. Löwis
> 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

Re: Unicode list

2007-03-31 Thread Paul Boddie
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: >

Unicode list

2007-03-31 Thread Rehceb Rotkiv
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