Bug or feature: double strings as one

M

MRAB

Jan said:
09-08-2009 o 23:43:14 r said:
#-- el bueno --#
"hello i am a very long string that\
does not like newlines so please \
escape me, Thank you!"

You probably ment: """hello i am... [etc.]

Anyway... You're right that generally it's good idea to define
dialog prompts and such stuff separately rather that to hardcode
it, especially in big projects. Then certainly multiline
string literals are useful (though, if you need to get rid of
newlines, IMHO "el feo" method is more elegant and less error
prone than your "el bueno" [possible invisible space after '\']).

But there are plenty of other situations when it's better
(in practice) to have strings (even long) together with your
code, e.g. log information for debugging, or
Here's an idea that you're probably going to hate: indented strings. :)

A string prefixed with 'i' would be an 'indented' string. Leading space
and tab characters at the start of the string (just after the quote) or
the start of each line within a multiline string would be ignored.
Line 2
"""
'Line 1\n Line 2\n' Line 2
"""
'Line 1\nLine 2\n'

An additional feature could be to make '\ ' == ' ', perhaps only for
indented strings if you're worried that it could breaking existing code:
\ Line 2
"""
'Line 1\n Line 2\n'

This would save you having to write '\x20'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,142
Latest member
DewittMill
Top