type() new style class instance says "class", not "ObjectType"
Guido van Rossum
guido at python.org
Fri Apr 12 14:49:17 EDT 2002
"David Mertz, Ph.D." wrote:
> Unfortunately, there's more to it than this. There still is--and
> presumably always will be--a difference between "instances" and other
> types of things. For example, a list is a mutable sequence that has
> some items in it. In contrast, an instance object--whether new style or
> old style (and w/ or w/o __slots__)--is a thing that has some
> attributes. The basic shape of the data will always be different. The
> type/class unification doesn't change that.
Hm...
So after
class C(list):
def appendmany(self, *args):
for arg in args:
self.append(arg)
Do you consider a C instance to be a list or an instance?
You might look at the presence of a __dict__ attribute
storing instance attributes as the distinguishing factor.
But then what would you do after
class D(list):
__slots__ = ["foo"]
List or instance? The shape of a D instance is the same
as the shape of a list, but with an extra slot added.
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-list
mailing list