dynamic type variable

Paddy paddy3118 at googlemail.com
Mon Jan 21 05:21:50 CET 2008


On Jan 21, 2:37 am, "J. Peng" <jp... at block.duxieweb.com> wrote:
> Python's variable is dynamic type,is it?
> But why this can't work?
>
> >>> 3 + 'a'
>
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> TypeError: unsupported operand type(s) for +: 'int' and 'str'
>
> So I see the number 3 can't be converted to string type automacially.

Hi,
You are probably confusing Dynamic typing with Weak typing.
Python is both dynamically and strongly typed. Perl is
both dynamically and weakly typed. It is Perls weak typing
that allows automatic conversion between dissimilar types.

See: http://en.wikipedia.org/wiki/Type_system

- Paddy.



More information about the Python-list mailing list