Static Typing in Python
Dang Griffith
google0 at lazytwinacres.net
Sat Mar 13 07:10:27 EST 2004
On Sat, 13 Mar 2004 07:07:50 +0000 (GMT), Premshree Pillai
<premshree_python at yahoo.co.in> wrote:
> --- Jacek Generowicz <jacek.generowicz at cern.ch>
>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. Is there
>something like it in Python?
No, but you can use pychecker to get similar results.
>Don't you think forced variable declaration is an
>important requirement in a language?
Not really. Forced variable initialization is what's important.
Unlike C, et al, and Perl, variables don't have a default
initial value. If you try reference a variable that hasn't been
initialized ("bound to a value", in python lingo), python raises a
NameError exception.
--dang
p.s.
I know technically Perl initializes to 'undef', but it's magically
treated as 0 or an empty string, depending on context, so the
effect is much the same.
More information about the Python-list
mailing list