strong/weak - dynamic/static [Was: Getting started]
Mark McEahern
marklists at mceahern.com
Thu Sep 19 10:25:16 EDT 2002
[sismex01 at hebmex.com]
> Python is definitely NOT weakly typed, it's dynamicly-strong
> typed. A variable, being only a "reference to *any* object"
> may refer to any object, but that object (see the difference?)
> may not change it's functionality or type during runtime.
Whatchoo talkin' bout Willis?
I don't have any practical use for the following, but it seems to
demonstrate that what you said is not true...
$ python
Python 2.2.1 (#1, Jun 25 2002, 10:55:46)
[GCC 2.95.3-5 (cygwin special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> class foo:
... def fooize(self):
... print self.__class__.__name__
...
>>> class bar:
... def barize(self):
... print self.__class__.__name__
...
>>> f = foo()
>>> f.fooize()
foo
>>> f.__class__ = bar
>>> f.fooize()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: bar instance has no attribute 'fooize'
>>> f.barize()
bar
// m
-
More information about the Python-list
mailing list