Is Python type safe?

Aahz aahz at pythoncraft.com
Tue Mar 16 17:25:37 EST 2004


In article <536ki1-lp3.ln1 at valpo.de>, Mathias Waack  <M.Waack at gmx.de> wrote:
>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.  
>
>Thats not true, Java doesn't let you add an integer to a string. It
>only looks like that because of implicit type conversion. BTW the
>same holds for C++ if you are using a string type which allows this
>conversion. 

Ditto Python, but Python by default doesn't do implicit type conversion
and it's strongly discouraged.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"usenet imitates usenet"  --Darkhawk



More information about the Python-list mailing list