Re: Problem writing some strings (UnicodeEncodeError)

2014-01-13 Thread Paulo da Silva
Em 13-01-2014 17:29, Peter Otten escreveu: > Paulo da Silva wrote: > >> Em 13-01-2014 08:58, Peter Otten escreveu: > > I looked around in the stdlib and found shlex.quote(). It uses ' instead of > " which simplifies things, and special-cases only ': > print(shlex.quote("alpha'beta")) > 'a

Re: Problem writing some strings (UnicodeEncodeError)

2014-01-13 Thread Peter Otten
Paulo da Silva wrote: > Em 13-01-2014 08:58, Peter Otten escreveu: >> Peter Otten wrote: >> >>> Paulo da Silva wrote: >>> Em 12-01-2014 20:29, Peter Otten escreveu: > Paulo da Silva wrote: > >>> but I have not tried it myself. Also, some bytes may need to be >>> escaped, eith

Re: Problem writing some strings (UnicodeEncodeError)

2014-01-13 Thread Paulo da Silva
Em 13-01-2014 08:58, Peter Otten escreveu: > Peter Otten wrote: > >> Paulo da Silva wrote: >> >>> Em 12-01-2014 20:29, Peter Otten escreveu: Paulo da Silva wrote: >> but I have not tried it myself. Also, some bytes may need to be >> escaped, either to be understood by the shell,

Re: Problem writing some strings (UnicodeEncodeError)

2014-01-13 Thread Peter Otten
Peter Otten wrote: > Paulo da Silva wrote: > >> Em 12-01-2014 20:29, Peter Otten escreveu: >>> Paulo da Silva wrote: >>> > but I have not tried it myself. Also, some bytes may need to be > escaped, either to be understood by the shell, or to address security > concerns: > >>

Re: Problem writing some strings (UnicodeEncodeError)

2014-01-13 Thread Peter Otten
Paulo da Silva wrote: > Em 12-01-2014 20:29, Peter Otten escreveu: >> Paulo da Silva wrote: >> but I have not tried it myself. Also, some bytes may need to be escaped, either to be understood by the shell, or to address security concerns: >>> >>> Since I am puting the file nam

Re: Problem writing some strings (UnicodeEncodeError)

2014-01-12 Thread Paulo da Silva
Em 12-01-2014 20:29, Peter Otten escreveu: > Paulo da Silva wrote: > >>> but I have not tried it myself. Also, some bytes may need to be escaped, >>> either to be understood by the shell, or to address security concerns: >>> >> >> Since I am puting the file names between "", the only char that nee

Re: Problem writing some strings (UnicodeEncodeError)

2014-01-12 Thread Peter Otten
Paulo da Silva wrote: >> but I have not tried it myself. Also, some bytes may need to be escaped, >> either to be understood by the shell, or to address security concerns: >> > > Since I am puting the file names between "", the only char that needs to > be escaped is the " itself. What about the

Re: Problem writing some strings (UnicodeEncodeError)

2014-01-12 Thread Paulo da Silva
> > I think instead of the hard way sketched out above it will be sufficient to > specify the error handler when opening the destination file > > shf = open(bashfilename, 'w', errors="surrogateescape") This seems to fix everything! I tried with a small test set and it worked. > > but I have no

Re: Problem writing some strings (UnicodeEncodeError)

2014-01-12 Thread Peter Otten
Paulo da Silva wrote: > Em 12-01-2014 16:23, Peter Otten escreveu: >> Paulo da Silva wrote: >> >>> I am using a python3 script to produce a bash script from lots of >>> filenames got using os.walk. >>> >>> I have a template string for each bash command in which I replace a >>> special string with

Re: Problem writing some strings (UnicodeEncodeError)

2014-01-12 Thread Paulo da Silva
Em 12-01-2014 16:23, Peter Otten escreveu: > Paulo da Silva wrote: > >> I am using a python3 script to produce a bash script from lots of >> filenames got using os.walk. >> >> I have a template string for each bash command in which I replace a >> special string with the filename and then write the

Re: Problem writing some strings (UnicodeEncodeError)

2014-01-12 Thread Emile van Sebille
On 01/12/2014 07:36 AM, Paulo da Silva wrote: Hi! I am using a python3 script to produce a bash script from lots of filenames got using os.walk. I have a template string for each bash command in which I replace a special string with the filename and then write the command to the bash script fil

Re: Problem writing some strings (UnicodeEncodeError)

2014-01-12 Thread Peter Otten
Paulo da Silva wrote: > I am using a python3 script to produce a bash script from lots of > filenames got using os.walk. > > I have a template string for each bash command in which I replace a > special string with the filename and then write the command to the bash > script file. > > Something

Re: Problem writing some strings (UnicodeEncodeError)

2014-01-12 Thread Albert-Jan Roskam
On Sun, 1/12/14, Paulo da Silva wrote: Subject: Problem writing some strings (UnicodeEncodeError) To: python-list@python.org Date: Sunday, January 12, 2014, 4:36 PM Hi! I am using a python3 script to produce a bash script from lots of filena