Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Object and type class
Hi, i'm a bit confused about type class and object class. I know that every normal class and built-in type are instance of type class and inherit from object class (is that correct? please correct me if i'm wrong). But when i try this:
It printed: True

Why is that? I thought object is the base class of list not the class which list was created from !. Can anybody show me the relationship between object class, type class, normal class, built-in type like list and string
Have a look here how isinstance() works
All objects inherit from object. Testing objects against object should be always True, even if you check type against object.

The normal use is:
my_object = [1, 2, 3]
print(isinstance(my_object, list))
print(isinstance(my_object, tuple))
True False
My code examples are always for Python >=3.6.0
Almost dead, but too lazy to die:
All humans together. We don't need politicians!

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Object of type Scoreboard is not JSON serializable lsepolis123 9 683 Aug-13-2019, 11:22 AM
Last Post: lsepolis123
  class returns NoneType Object istemihan 0 121 Aug-12-2019, 11:47 AM
Last Post: istemihan
  Return a value when I equal an object from a class ihouses 4 253 Jul-10-2019, 02:44 AM
Last Post: SheeppOSU
  How to save a class object to a file? SheeppOSU 2 228 Jun-22-2019, 11:54 PM
Last Post: metulburr
  saving (in text or binary) an object under a defined class cai0824 3 383 May-12-2019, 08:55 AM
Last Post: snippsat
  Object type of Node to json bhojendra 4 397 Apr-28-2019, 01:36 PM
Last Post: bhojendra
  TypeError: object of type 'NoneType' has no len() - what do it mean? leviathan54 4 1,275 Apr-20-2019, 12:04 PM
Last Post: leviathan54
  Getting error "Type error-a bytes-like object..." mrapple2020 1 908 Apr-06-2019, 06:37 PM
Last Post: mrapple2020
  Why Can't I call base class function for my derived class object? AmirAB 2 353 Feb-13-2019, 03:04 PM
Last Post: snippsat
  General query regarding conversion of dict to class object saisankalpj 0 335 Jan-16-2019, 01:58 PM
Last Post: saisankalpj

Forum Jump:

Users browsing this thread: 1 Guest(s)