Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

Line Breaks

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


suzieprogrammer at gmail

Nov 23, 2009, 10:45 AM

Post #1 of 7 (203 views)
Permalink
Line Breaks

Hi;
I have the following line of code I'm sending to postfix:

msg = 'A Message From %s:\n\n %s' % (string.replace(customer, '_', ' '),
msg)

Unfortunately, it ignores the line breaks. I also tried %0A but that was
ignored also. Please advise.
TIA,
Suzie


apt.shansen at gmail

Nov 23, 2009, 11:22 AM

Post #2 of 7 (192 views)
Permalink
Re: Line Breaks [In reply to]

On Mon, Nov 23, 2009 at 10:45 AM, Susan Day <suzieprogrammer [at] gmail>wrote:

> Hi;
> I have the following line of code I'm sending to postfix:
>
> msg = 'A Message From %s:\n\n %s' % (string.replace(customer, '_', ' '),
> msg)
>
> Unfortunately, it ignores the line breaks. I also tried %0A but that was
> ignored also. Please advise.
>

Does it ignore ALL line breaks-- or just doubled ones like \n\n? E.g., blank
lines?

I *think* its probably the latter, and doing msg.replace('\n\n', '\n \n')
will make it work. That'd end up with a single space on those blank lines.

HTH,

--S


gherron at islandtraining

Nov 23, 2009, 11:26 AM

Post #3 of 7 (193 views)
Permalink
Re: Line Breaks [In reply to]

Susan Day wrote:
> Hi;
> I have the following line of code I'm sending to postfix:
>
> msg = 'A Message From %s:\n\n %s' % (string.replace(customer, '_', '
> '), msg)
>
> Unfortunately, it ignores the line breaks. I also tried %0A but that
> was ignored also. Please advise.
> TIA,
> Suzie
That line does not ignore line breaks. Proof:
>>> print 'A Message From %s:\n\n %s' % ('someone','some message')
A Message From someone:

some message


So... *Exactly* what are you doing with msg, and *exactly* what is your
evidence that line breaks are being ignored. With that information,
perhaps we can identify and solve the real problem you're having.

Gary Herron


--
http://mail.python.org/mailman/listinfo/python-list


suzieprogrammer at gmail

Nov 23, 2009, 11:46 AM

Post #4 of 7 (190 views)
Permalink
Re: Line Breaks [In reply to]

On Mon, Nov 23, 2009 at 2:26 PM, Gary Herron <gherron [at] islandtraining>wrote:

> >>> print 'A Message From %s:\n\n %s' % ('someone','some message')
> A Message From someone:
>
> some message
>
>
> So... *Exactly* what are you doing with msg, and *exactly* what is your
> evidence that line breaks are being ignored. With that information, perhaps
> we can identify and solve the real problem you're having.
>

First, it does in fact ignore all line breaks, not just double line breaks.
Here's what I'm doing:
session.sendmail(clientEmail, ourEmail2, header+msg)
The email sent out has the message sans breaks.
TIA,
Suzie


darcy at druid

Nov 23, 2009, 1:31 PM

Post #5 of 7 (185 views)
Permalink
Re: Line Breaks [In reply to]

On Mon, 23 Nov 2009 14:46:23 -0500
Susan Day <suzieprogrammer [at] gmail> wrote:
> First, it does in fact ignore all line breaks, not just double line breaks.
> Here's what I'm doing:
> session.sendmail(clientEmail, ourEmail2, header+msg)
> The email sent out has the message sans breaks.

You should really post an entire script that runs and shows the error
so that we can run it (changing the email address of course) to see
what it does.

--
D'Arcy J.M. Cain <darcy [at] druid> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
--
http://mail.python.org/mailman/listinfo/python-list


lie.1296 at gmail

Nov 23, 2009, 8:01 PM

Post #6 of 7 (183 views)
Permalink
Re: Line Breaks [In reply to]

D'Arcy J.M. Cain wrote:
> On Mon, 23 Nov 2009 14:46:23 -0500
> Susan Day <suzieprogrammer [at] gmail> wrote:
>> First, it does in fact ignore all line breaks, not just double line breaks.
>> Here's what I'm doing:
>> session.sendmail(clientEmail, ourEmail2, header+msg)
>> The email sent out has the message sans breaks.
>
> You should really post an entire script that runs and shows the error
> so that we can run it (changing the email address of course) to see
> what it does.
>

My guess: you're writing HTML email?

In HTML, superfluous whitespace is ignored. Use <br /> for line break
&nbsp; for space, or enclose the text in <pre>
--
http://mail.python.org/mailman/listinfo/python-list


gherron at islandtraining

Nov 23, 2009, 9:23 PM

Post #7 of 7 (181 views)
Permalink
Re: Line Breaks [In reply to]

Susan Day wrote:
> On Mon, Nov 23, 2009 at 2:26 PM, Gary Herron
> <gherron [at] islandtraining <mailto:gherron [at] islandtraining>> wrote:
>
> >>> print 'A Message From %s:\n\n %s' % ('someone','some message')
> A Message From someone:
>
> some message
>
>
> So... *Exactly* what are you doing with msg, and *exactly* what
> is your evidence that line breaks are being ignored. With that
> information, perhaps we can identify and solve the real problem
> you're having.
>
>
> First, it does in fact ignore all line breaks, not just double line
> breaks.
> Here's what I'm doing:
> session.sendmail(clientEmail, ourEmail2, header+msg)
> The email sent out has the message sans breaks.
> TIA,
> Suzie


You say "it does in fact ignore all line breaks", but which "IT" are you
talking about. The line of code you originally showed us
msg = 'A Message From %s:\n\n %s' % (string.replace(customer,
'_', ' '), msg)
in fact does NOT ignore line breaks, and I demonstrated that to you.
Your problem is somewhere else.

Now you've shown us one more line of code. But why only one? Why make
it so hard for us to help you? I for one will consider volunteering
more time on this problem only if I get a small, complete program, which
demonstrates the problem, and which I can cut and paste.

Gary Herron



--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.