An object is an instance (or not)?
rosuav at gmail.com
Wed Jan 28 01:30:32 CET 2015
On Wed, Jan 28, 2015 at 11:17 AM, Mario Figueiredo <marfig at gmail.com> wrote:
> Means the object is capable of participating in inheritance and/or
> polymorphism. An instance of an object is capable of doing so, per its
> class definitions. Whereas a Python class object is not.
> >>> class Master:
> def func(self):
> >>> class Sub(Master):
> >>> Sub.func()
> TypeError: func() missing 1 required positional argument: 'self'
> But somehow I think you knew the answer to all these questions and were
> instead being snarky.
I have no idea what you're proving here. You just showed that the
class has a function attached to it, and you didn't provide enough
arguments to it. And types have their own set of attributes and
['__abstractmethods__', '__base__', '__bases__', '__basicsize__',
'__call__', '__class__', '__delattr__', '__dict__', '__dictoffset__',
'__dir__', '__doc__', '__eq__', '__flags__', '__format__', '__ge__',
'__getattribute__', '__gt__', '__hash__', '__init__',
'__instancecheck__', '__itemsize__', '__le__', '__lt__', '__module__',
'__mro__', '__name__', '__ne__', '__new__', '__prepare__',
'__qualname__', '__reduce__', '__reduce_ex__', '__repr__',
'__setattr__', '__sizeof__', '__str__', '__subclasscheck__',
'__subclasses__', '__subclasshook__', '__text_signature__',
Most of those are inherited from object, but some aren't.
What are you demonstrating?
More information about the Python-list