strong/weak - dynamic/static [Was: Getting started]

Henrik Motakef henrik.motakef at web.de
Thu Sep 19 11:27:26 EDT 2002


"Mark McEahern" <marklists at mceahern.com> writes:

> $ 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()
>>> b = foo()
>>> b.__class__ = bar
>>> f.fooize()
foo
>>> b.barize()
bar
>>> type(f) == type(b)
1
>>> type(f)
<type 'instance'>
>>>

There's a difference between a type and a class, I guess...



More information about the Python-list mailing list