text formatting question

2013-02-28 Thread idy
I have a text string of this format 

Error = 
'XYC.12345455LOcation/user/data/MYGLE-INGXYC.23344566LOcation/user/data/INGE-FTYXYC.22334566LOcation/user/data/GETN-YUNXYC.12345455LOcation/user/data/MYGLE-INGXYC.111LOcation/user/data/INGE-FTYXYC.333LOcation/user/data/GETN-YUN'

I need to write this to mail body as with following format in multiple lines

XYC.12345455-LOcation/user/data/MYGLE-ING
XYC.23344566-LOcation/user/data/INGE-FTY
XYC.22334566LOcation/user/data/GETN-YUN
XYC.12345455LOcation/user/data/MYGLE-ING
XYC.111LOcation/user/data/INGE-FTY
XYC.333LOcation/user/data/GETN-YUN

Note (XYC is common for all the text , rest of the fields are not constant. 
Please help
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: text formatting question

2013-02-28 Thread idy
On Friday, March 1, 2013 12:23:41 PM UTC+5:30, Chris Angelico wrote:
> On Fri, Mar 1, 2013 at 5:49 PM, idy  wrote:
> 
> > Error = 
> > 'XYC.12345455LOcation/user/data/MYGLE-INGXYC.23344566LOcation/user/data/INGE-FTYXYC.22334566LOcation/user/data/GETN-YUNXYC.12345455LOcation/user/data/MYGLE-INGXYC.111LOcation/user/data/INGE-FTYXYC.333LOcation/user/data/GETN-YUN'
> 
> >
> 
> > I need to write this to mail body as with following format in multiple lines
> 
> >
> 
> > XYC.12345455-LOcation/user/data/MYGLE-ING
> 
> > XYC.23344566-LOcation/user/data/INGE-FTY
> 
> > XYC.22334566LOcation/user/data/GETN-YUN
> 
> > XYC.12345455LOcation/user/data/MYGLE-ING
> 
> > XYC.111LOcation/user/data/INGE-FTY
> 
> > XYC.333LOcation/user/data/GETN-YUN
> 
> 
> 
> You want to break the line immediately before the 'XYC'? That's quite
> 
> easy; the line break is a character like any other, and can be used in
> 
> a replace() call:
> 
> 
> 
> formatted_error = Error.replace("XYC","\nXYC")
> 
> 
> 
> If that's not the case, can you clarify what you need to do to divide it?
> 
> 
> 
> Chris Angelico

Chris,

Thanks this works great !!! 
-- 
http://mail.python.org/mailman/listinfo/python-list