Is Python type safe?

Peter Hansen peter at
Tue Mar 16 21:29:20 CET 2004

Roy Smith wrote:

> Neither C++ nor Python will let you add the integer 3 to the string 
> "four", but use different mechanisms to prevent it.  Oddly enough, Java 
> (in a perl-like, but admittedly convenient, stab at automagic 
> polymorphism) will let you add them.  No clue what C# does.

It's been a while since I Java-ed, but doesn't it "append" them, as in 
convert the integer to a string and then join the two strings, rather 
than "add" them (which I take to mean "calculate the sum of")?

(That's probably what you meant, but I'm just checking.  I'd be 
surprised to find that Java actually performed the string-to-value 
conversion implicitly.)


More information about the Python-list mailing list