The definition of an object in Python

Avi Kak kak at
Sun Jul 13 19:25:13 CEST 2003


  Please forgive me if my question is too silly or just not 

  Wesley Chun in his book (Core Python Programming) says that 
  **everything** in Python is an object.  So I became curious
  about the precise definition of an object in Python.  My
  curiosity was also driven by Wesley's statement that while
  every class instance is an object, not every object is a 
  class instance.

  Wesley says that every Python object must possess the following
  three characteristics: 1) an identity, which can be retrieved 
  by the function id(); 2) a type, which can be retrieved by
  the function type(); and 3) a value.

  But when I do the following

      mystring = 'hello'


      print mystring.type()

  Python complains that mystring does not possess the attributes
  id and type.

  So now I am confused.  Any help with the resolution of this 
  issue would be much appreciated.

Avi Kak
kak at

More information about the Python-list mailing list