Re: removing characters before writing to file

2006-02-09 Thread Stefan Neumann
[EMAIL PROTECTED] wrote: > hi > i have some output that returns a lines of tuples eg > > ('sometext1', 1421248118, 1, 'P ') > ('sometext2', 1421248338, 2, 'S ') > and so on > > If the braces are always at the begining and at the end of the string, you could also use: >>> "('sometext1

Re: removing characters before writing to file

2006-02-09 Thread bonono
[EMAIL PROTECTED] wrote: > hi > i have some output that returns a lines of tuples eg > > ('sometext1', 1421248118, 1, 'P ') > ('sometext2', 1421248338, 2, 'S ') > and so on > > > I tried this > re.sub(r" '() ",'',str(output)) but it only get rid of the ' and not > the braces. I need to write

Re: removing characters before writing to file

2006-02-09 Thread Peter Otten
[EMAIL PROTECTED] wrote: > i have some output that returns a lines of tuples eg > > ('sometext1', 1421248118, 1, 'P ') > ('sometext2', 1421248338, 2, 'S ') > and so on > > > I tried this > re.sub(r" '() ",'',str(output)) but it only get rid of the ' and not > the braces. I need to write the

Re: removing characters before writing to file

2006-02-09 Thread John Zenger
As mentioned in the thread, it makes sense to build the desired output you want from the tuple, rather than converting the tuple to a string and then doing replace operations on the string. If you do want to go the replace route, you don't need the power of regex substitutions for what you are

Re: removing characters before writing to file

2006-02-08 Thread Frank Potter
r=re.compile(r"(\(')|( '\))|'")print r.sub('',str(output))On 8 Feb 2006 18:35:01 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: hii have some output that returns a lines of tuples egtr('sometext1', 1421248118, 1, 'P ')('sometext2', 1421248338, 2, 'S ')and so onI tried thisre.sub(r" '() ",

Re: removing characters before writing to file

2006-02-08 Thread jawahh
', '.join(map(str,output)) -- http://mail.python.org/mailman/listinfo/python-list

removing characters before writing to file

2006-02-08 Thread eight02645999
hi i have some output that returns a lines of tuples eg ('sometext1', 1421248118, 1, 'P ') ('sometext2', 1421248338, 2, 'S ') and so on I tried this re.sub(r" '() ",'',str(output)) but it only get rid of the ' and not the braces. I need to write the output to a file such that sometext1, 142