l learned that Python is strong-dynamic typed language.
dynamic: type of a variable is determined at execution time NOT compiling time. For this part, I can understand that type is determined when a value(type of course) is assigned to the variable.
strong: you can NOT change the type of a variable. But this is not the real case:
>>> a = 1
>>> type(a)
<type 'int'>
>>> a = 's'
>>> type(a)
<type 'str'>
From the code above, I can change the type of variable a from int to str.
How can this happen? Could I say Python is a weak-typed language?
EDIT:
If you can give me a code snippet that shows how strong-dynamic typing affect Python programming, I would appreciate it pretty much! During my usual coding, I never care about the strong-dynamic typing issues. It seldom affects my code function as well. Weird!
EDIT:
Conclusion from the answers:
- Only object/value has type attribute. Variable has no type.
- (Strong) Type determines what operations can be performed over/between objects/values (maybe variables referring to them).
- (Dynamic) Type means variable just a label (reference to object/value). This label can refer to any object/value of any type.