Static Typing in Python

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Tue Mar 16 10:34:13 CET 2004


Premshree Pillai wrote:
>  --- Jacek Generowicz <jacek.generowicz at cern.ch>
> wrote: > 
> 
>>On 13 Mar 2004, at 08:07, Premshree Pillai wrote:
>>
>>
>>>Yes, I am aware that Python is dynamically typed,
>>
>>and
>>
>>>so is Perl, right? In Perl, we have the "use
>>
>>strict
>>
>>>vars" pragma to force variable declaration.
>>
>>I'm no Perler ... but by reading a bit of
>>documentation, I get the 
>>impression that you are a bit confused about what
>>"use strict 'vars'" 
>>really does. It seems to be some mish-mash of
>>concepts: it imposes the 
>>necessity to fully qualify names, to declare (the
>>existence, not the 
>>type of) variables with "our", and does some control
>>of scoping rules.
>>
> 
> 
> Err...you probably have the wrong idea of static
> typing, I think. Static typing has to do with explicit
> declaration (initialization) of variables (and not of
> variable types).

I beg your pardon ? Why do you thinks it is called 'static *typing*'?
Static typing has to do with compile-time *type* checking, not with 
variables declaration. Believe it or no, there are statically (and 
strongly) typed languages that does not enforce variable declaration nor 
even type declaration - this is called type inference, and you can have 
an exemple in OCaml.


> Like in C, C++, etc, Python too is
> strongly typed, 

C is certainly not what I'd call a 'strongly' typed langage, since you 
can cast *any* variable to *any* type without the compiler complaining. 
If you want *strong* static typing, go for Ada.

(snip)

Bruno




More information about the Python-list mailing list