Getting started

Terry Reedy tjreedy at udel.edu
Wed Sep 25 06:45:38 CEST 2002


"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