Myths - The Python language is weakly typed

December 2016




Myth


The programming language Python is weakly typed, like PHP or Basic.

Reality


FALSE.

Explanations

Python is a language with dynamic typing.


Python is a high-level programming language whose asset is code readability
Though its syntax is easy to use, it is very powerful and can be use for all purposes and its standard library is large and comprehensive. It make use of indentation as block delimiters( an unusual method among popular programming languages).

Python provide a platform supporting multiple programming paradigms (primarily object oriented, imperative, and functional) and consists of a fully dynamic type system and automatic memory management, similar to Perl and is often used as a scripting language.

Demonstration


>>> a="toto"
>>> b=5
>>> print a+b
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: cannot concatenate 'str' and 'int' objects
>>>


Python made it clear that you can not concatenate a string and an integer.
If the Python was a weak typed language, he displayed "toto5.

(PHP is a language for low dynamic typing, the C + + and Java languages are strong static typing.)

Related :

This document entitled « Myths - The Python language is weakly typed » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.