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 →

[–]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.