Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Join multiline strings with '' , ' ' or '\n'? #16

Closed
andresriancho opened this issue Mar 30, 2015 · 1 comment
Closed

Join multiline strings with '' , ' ' or '\n'? #16

andresriancho opened this issue Mar 30, 2015 · 1 comment

Comments

@andresriancho
Copy link
Contributor

Join multiline strings with '' or '\n'? That's something I'm not sure about.

Joining with empty strings

If we join using '' the long strings that don't contain new lines will look like:

foo = ["abc def hello world",
        " rock stars"]

Result text: abc def hello world rock stars
Rendered markdown: <p>abc def hello world rock stars</p>

Note: The contributor needs to remember to add the empty space before "rock"

And when a contributor wants to add a new line he needs to add it explicitly (which sounds good):

foo = ["abc def hello world\n",
        "rock stars"]

Result text: abc def hello world rock stars
Rendered markdown:

<p>abc def hello world
rock stars</p>

Note: The contributor needs to remember to add a double \n\n if he wants two paragraphs

This is the case for two different paragraphs

foo = ["abc def hello world\n\n",
        "rock stars"]

Result text: abc def hello world rock stars
Rendered markdown:

<p>abc def hello world</p>
<p>rock stars</p>

Joining with a space

If we join with a space we're "fixing" the fact that the contributor needs to remember to add an empty space at the beginning of each line. But that's not very explicit and might confuse contributors.

Joining with a new line

foo = ["abc def hello world",
        " rock stars"]

Result text: abc def hello world\n rock stars
Rendered markdown:

<p>abc def hello world
rock stars</p>
foo = ["abc def hello world",
        "\n",
        " rock stars"]

Result text: abc def hello world\n\n rock stars
Rendered markdown:

<p>abc def hello world</p>
<p>rock stars</p>

This seems to be the cleanest.

Ideas? Comments?

@m0sth8
Copy link
Contributor

m0sth8 commented Mar 31, 2015

👍 for Joining with a space

@andresriancho andresriancho self-assigned this Apr 2, 2015
andresriancho added a commit to vulndb/python-sdk that referenced this issue Apr 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants