Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #40228

Re: text formatting question

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.031
X-Spam-Evidence '*H*': 0.94; '*S*': 0.00; 'subject:text': 0.05; 'subject:question': 0.08; 'other,': 0.09; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'wrote:': 0.17; 'header :In-Reply-To:1': 0.25; 'message-id:@mail.gmail.com': 0.27; 'lines': 0.28; 'chris': 0.28; 'case,': 0.29; 'character': 0.29; 'fri,': 0.30; 'error': 0.30; 'clarify': 0.33; 'to:addr:python- list': 0.33; 'received:google.com': 0.34; 'pm,': 0.35; 'received:209.85': 0.35; 'quite': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; '2013': 0.84; 'divide': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=AijIjWcyPFHFJwbyNnNhWwQ8GM9R78CZuh+sikckzGc=; b=eRetq48cl0TSMnoJOjOAqC0dlBfgNQapivQw+Jr2FyyesZ8fzBi911efwGuic4xQBf 6J4KOdOQ3vCmzX0ENv6Pm0yuV5mDIGt1N8fzSV70DKu+7qeUPiNFMiQ6AkbCriIdfzSw 5kUxUEJJd0t9zcWsvxRJr3Eie8/Nh4nrzW2B6u5Nj3OHzKQPpxxcyJFvk/4HesH1BXMt bzxg+8lCZdGJYqU84+72JSTASN+LwOkT67VOf5K49VW0apGWnUpnFfHozzB0ZvxUIF3K x+jPjjToLXbTIvSooL1UCez6LDT4vK3HqRvMPAT/H3rB5dg3jy7ofvI4SzMbxrT1nCiT LmlQ==
MIME-Version 1.0
X-Received by 10.52.67.164 with SMTP id o4mr3159876vdt.42.1362120821907; Thu, 28 Feb 2013 22:53:41 -0800 (PST)
In-Reply-To <0a6178f9-51ef-4edc-b87f-2631d667797f@googlegroups.com>
References <0a6178f9-51ef-4edc-b87f-2631d667797f@googlegroups.com>
Date Fri, 1 Mar 2013 17:53:41 +1100
Subject Re: text formatting question
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2703.1362120831.2939.python-list@python.org> (permalink)
Lines 21
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1362120831 news.xs4all.nl 6945 [2001:888:2000:d::a6]:58020
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:40228

Show key headers only | View raw


On Fri, Mar 1, 2013 at 5:49 PM, idy <idhayham@gmail.com> wrote:
> Error = 'XYC.12345455LOcation/user/data/MYGLE-INGXYC.23344566LOcation/user/data/INGE-FTYXYC.22334566LOcation/user/data/GETN-YUNXYC.12345455LOcation/user/data/MYGLE-INGXYC.1111111LOcation/user/data/INGE-FTYXYC.3333333LOcation/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.1111111LOcation/user/data/INGE-FTY
> XYC.3333333LOcation/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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

text formatting question idy <idhayham@gmail.com> - 2013-02-28 22:49 -0800
  Re: text formatting question Chris Angelico <rosuav@gmail.com> - 2013-03-01 17:53 +1100
    Re: text formatting question idy <idhayham@gmail.com> - 2013-02-28 23:08 -0800
      Re: text formatting question Dave Angel <davea@davea.name> - 2013-03-01 08:52 -0500
      Re: text formatting question Chris Angelico <rosuav@gmail.com> - 2013-03-02 00:57 +1100
    Re: text formatting question idy <idhayham@gmail.com> - 2013-02-28 23:08 -0800

csiph-web