Need cleanup advice for multiline string
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Wed Aug 12 11:26:12 EDT 2009
On Wed, 12 Aug 2009 07:47:58 -0700, Robert Dailey wrote:
> On Aug 12, 9:41 am, Robert Dailey <rcdai... at gmail.com> wrote:
...
> > I was actually joking about my remark, I was making fun of the fact
> > that Bearophile took my figure of speech literally.
Keep in mind that the Internet is a global forum, and not everyone here
speaks English as a first language. I believe Bearophile is one of those.
Although his, or possibly her, English is excellent, it wouldn't surprise
me that (s)he would misinterpret "guys" as just referring to men. I'm a
native English speaker, and I would have done the same.
> > I have worked with
> > a lot of women in the past and they even use "guys" to refer to
> > everyone in a room (When there were obviously other females in that
> > room as well).
Yes, I've seen this myself, but it's still uncommon enough to surprise me
every time I see it.
> > On a more serious note, I do apologize to those offended by my remark.
> > I realize that these things can be a touchy subject for some people. I
> > expected more of a laid-back attitude from everyone. No need to be so
> > serious all the time. I cannot completely doubt that there are logical
> > women out there. I just haven't seen one yet.
That's okay, I haven't seen terribly many logical men out there either.
> Oh, one last thing... So everyone knows, I chose the following
> formatting solution to multiline strings:
>
> def MyFunction():
> multilineString = (
> 'This is a string that spans '
> 'multiple lines.'
> )
> print( multilineString )
>
> I think this is as good as it is going to get for my personal needs.
> However, I do not like having to put a space at the end of each
> string.
So put them at the beginning of the next line. It makes the space more
obvious, so it's clearer what you have done. That's what I sometimes do.
> I've also done this in the past, which is slightly more ugly:
>
> multilineString = (
> 'This is a string that spans',
> 'multiple lines.'
> )
> print( ' '.join( multilineString ) )
It's also less efficient, as it does the concatenation at runtime instead
of compile time. But for a small script, that's not likely to be a
problem worth worrying about.
--
Steven
More information about the Python-list
mailing list