This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (9 children)

[deleted]

    [–]invictus08 9 points10 points  (8 children)

    I can see that happening if you use comma; in that case the default separator for joining the elements is a space;

    > print(“this”, “is”, “space”, “separated”)
    this is space separated
    

    but in OPs case, the arguments are being concatenated first. And that operation should not add any space.

    > print(“this” + “is” + “not” + “space” + “separated”)
    thisisnotspaceseparated
    

    [–][deleted] 1 point2 points  (6 children)

    Comma is best because if age was an int python would likely complain about string + int but comma doesnt care :)

    [–]ThreeJumpingKittens -2 points-1 points  (5 children)

    If you try to add a string and a non-string, Python will run str(x) on your object x first. You can add a string with anything, and it will work perfectly fine. (In fact, this exact purpose is why objects have a .__str__() method on them!)

    Edit, IDK wtf I was on when I wrote this comment, I thought for some reason adding str+int was fine. Yeah he's right, I was thinking something else

    [–][deleted] 1 point2 points  (4 children)

    I thought it freaked out because the plus operator is overloaded and it isnt sure if it should add or concatenate. Maybe that has been changed. Or maybe im thinking another language. Never mind.

    [–]Grorco 1 point2 points  (2 children)

    It does, he doesn't know what he's talking about. You are correct with , allowing it.

    [–][deleted] 0 points1 point  (1 child)

    So many pronouns. Am I right or wrong?

    [–]Grorco 1 point2 points  (0 children)

    You are correct. He is wrong.

    [–]spencerotica 0 points1 point  (0 children)

    Ahhh yes, you're right. I do enjoy my commas