Getting started

Adam Taylor ataylor at ucsd.edu
Fri Sep 27 15:59:42 EDT 2002


> Python types objects and their values rather than names and the fixed
> chunks of memory that names usually refer to in name-typed languages.
> Given a definition of type that sees typeness as inhering only in
> names rather than objects, then yes, Python is 'untyped'.  But how
> useful is such a viewpoint?  It obscures a real difference between
> data models.

Yes, I agree.  I think a better way to classify things (as pointed out
by Alex Martelli, referencing the Scheme spec) is as statically typed
vs. dynamically typed vs. untyped.  Basically, I think the best way to
talk about this stuff is summarized in this diagram:

                      Statically typed   Dynamically typed   Untyped
Strongly checked      ML                 Lisp,Python,Perl
Weakly checked        C                                      Assembler

With the term "weakly typed" being a morass best avoided (IMHO).

Adam

-----
"Terry Reedy" <tjreedy at udel.edu> wrote in message news:<Sbbk9.262614$z91.11379176 at bin3.nnrp.aus1.giganews.com>...
> "Adam Taylor" <ataylor at ucsd.edu> wrote in message
> news:mailman.1032917851.23864.python-list at python.org...
> > Based on this definition, it seems to me that Python _is_ untyped,
> > since the type of a variable can change arbitrarily in mid-program.
> 
> Python types objects and their values rather than names and the fixed
> chunks of memory that names usually refer to in name-typed languages.
> Given a definition of type that sees typeness as inhering only in
> names rather than objects, then yes, Python is 'untyped'.  But how
> useful is such a viewpoint?  It obscures a real difference between
> data models.
> 
> If a language has nested scopes and allows the type of a variable to
> be different in different scopes,  then the type associated with a
> particular name can change arbitrarily in mid-program (at scope
> changes) even if the name is strongly and statically typed within each
> scope.  One can say that the name represents different variables in
> the different contexts (scopes), but the net result is similar to what
> Python does.  Ie, one can view the rebinding of a name to an object of
> different type as implicitly defining a new scope with respect to that
> name.
> 
> Terry J. Reedy



More information about the Python-list mailing list