Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #91615 > unrolled thread

Re: Everything is an object in python - object class and type class

Started byrandom832@fastmail.us
First post2015-05-31 23:57 -0400
Last post2015-05-31 23:57 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  Re: Everything is an object in python - object class and type class random832@fastmail.us - 2015-05-31 23:57 -0400

#91615 — Re: Everything is an object in python - object class and type class

Fromrandom832@fastmail.us
Date2015-05-31 23:57 -0400
SubjectRe: Everything is an object in python - object class and type class
Message-ID<mailman.262.1433133429.5151.python-list@python.org>
On Sun, May 31, 2015, at 10:34, Eddilbert Macharia wrote:
> Hello All ,
> 
> I'm wrecking my head trying to understand. where the class object comes
> into play . 
> 
> Is it only meant to act as base class and does it mean there is an actual
> class called object in python which all the objects created using the
> class type inherit ?

Well, you _can_ create a proper instance if you want.

>>> x = object()
>>> x # incidentally, the repr method is called to produce this output
<object object at 0x1003b8090>
>>> id(x)
4298866832
>>> hash(x)
268679177

The other thing that object does is provide the default implementations
of these methods, so when you inherit from it you don't have to
implement them yourself (equality semantics based on object identity,
str based on repr, repr as shown above)

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web