Why is "int + string" possible in statically-typed C# but not in dynamically-typed Python?

Posted by Salvador Dali on Stack Overflow See other posts from Stack Overflow or by Salvador Dali
Published on 2013-10-23T21:23:28Z Indexed on 2013/10/23 21:54 UTC
Read the original article Hit count: 194

Filed under:
|
|

While studying C# I found it really strange, that dynamically typed Python will rise an error in the following code:

i = 5
print i + " "

whereas statically typed C# will normally proceed the similar code:

int i = 5;
Console.Write(i + " ");

I would expect other way around (in python I would be able to do this without any casting, but C# would require me to cast int to string or string to int).

Just to highlight, I am not asking what language is better, I am curious what was the reason behind implementing the language this way.

© Stack Overflow or respective owner

Related posts about c#

Related posts about python