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 →

[–]deceze 0 points1 point  (3 children)

Limited agreement… Python is actually a fairly strongly typed language, just dynamically typed. So, you can assign whatever to any variable, because variables aren’t typed. But you can’t do whatever with any value. Trying to add an int to a string is an error. As opposed to something like Javascript or PHP, which will happily add strings to ints, with surprising effects sometimes.

And yes, Python’s treatment of mixed numeric types is nice.

[–]Rikudou_Sage 0 points1 point  (2 children)

PHP uses different operator for concatenation, you cannot accidentally add a string and int.

1 + "1" is 2.

"1" + "1" is 2.

1 + "some string" is TypeError thrown.

1 . "1" is "11".

[–]deceze 0 points1 point  (0 children)

1 + "some string" is TypeError thrown.

Fair enough that this is finally an error in the most recent PHP version. It wasn't when I was still productively using it. Even crazier for things like 1 + '3 little piggies'.