[Tutor] new classes and default attribute

Lloyd Kvam pythontutor at venix.com
Wed Nov 19 00:20:15 EST 2003


An instance of the builtin types will return its value when referenced.
 >>> class I(int):
... 	pass
...
 >>> i = I(123)
 >>> i
123

An instance of a "normally" defined class returns type information.
 >>> class O(object):
... 	pass
...
 >>> o = O(123)
 >>> o
<__main__.O object at 0x016F0420>

Where does this difference in behavior come from?  Is there a __????__
that can be used when defining a class to get similar behavior?


-- 
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice:	603-653-8139
fax:	801-459-9582




More information about the Tutor mailing list