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

Rustom Mody rustompmody at gmail.com
Tue Jun 2 03:44:11 EDT 2015


On Tuesday, June 2, 2015 at 12:42:31 PM UTC+5:30, Steven D'Aprano wrote:
> On Tuesday 02 June 2015 10:24, TheDoctor wrote:
> 
> > A type is not an object in the same way an instantiated type is an object
> > -- anymore than a blueprint for a building is the building itself.
> 
> Nobody says that blueprints are *buildings*. But buildings are not the only 
> kind of object that exists.
> 
> Plates and spoons and knives and forks are objects.
> Cars and trucks and ships and planes are objects.
> Books and shoes and maps and compasses are objects.
> Buildings are objects.
> And blueprints of buildings are objects too.

You are using 'are' as if they are all the same 'are'. Are they?
Consider the type int.
It is supposed to model mathematical integers.
ie 1 ∈ int (in some sense)

Consider the generator
def int2():
  i = 0
  yield i
  while True:
    yield i
    yield -i

1 ∈ int2 [Not to mention 1 ∈ int2()]

Consider range(10) (in python2 and 3)
And finally [1,2,3,4]

1 ∈ all these
Are the '∈'s here same?  Similar?



More information about the Python-list mailing list