Myths - The Python language is weakly typed

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.)

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jean-François Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.
This document, titled « Myths - The Python language is weakly typed », is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).