The definition of an object in Python

Max M maxm at
Sun Jul 13 19:51:35 CEST 2003

Avi Kak wrote:

>   But when I do the following
>       mystring = 'hello'
>       print
>       print mystring.type()
>   Python complains that mystring does not possess the attributes
>   id and type.

mystring = 'hello'

print id(mystring)

print type(mystring)

 >>> 8985424
 >>> <type 'string'>

id and type are built in functions. Not methods on objects.

Wich imho is a good thing. This means that you can have methods on 
objects called id and type, without loosing the ablity to use these 

regards Max N

More information about the Python-list mailing list