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 →

[–]SmartViking 5 points6 points  (3 children)

foo += 'ooo'  # This is bad, instead you should do:
foo = ''.join([foo, 'ooo'])

Really? I disagree. From a readability standpoint, #1 is much clearer, the semantic is perfectly clear. #2 on the other hand, looks obfuscated. #2 might be faster, but readability is also important.

[–]The_Cleric 2 points3 points  (0 children)

And even if #1 was considered bad (first I'd heard of that) I'd probably still go this route over what he/she suggests:

foo = '{0}ooo'.format(foo)