bruno at modulix wrote:
> venk wrote:
> 
>>Hi,
>>  can some one properly explain the differences between class types and
>>classic classes? ... Still face problems in identifying what is what.
> 
> 
> I'm not sure I understand your question. Are you talking about the diff
> between old-style and new-style classes, or the diff between classes and
> metaclasses ?
> 
"new" classes inherit from object.  Classic classes do not.
"new" classes have a __new__ method.  Classic classes generally do not.
The type of a "new" class is types.TypeType
The type of a classic class is a classobj
The type of an instance of a "new" class is the name of the class
The type of an instnce of a classic class is an instance

This is shown below:
 >>> class A(object):
...   def __init__(self):
...     pass
...
 >>> a= A()
 >>> class B:
...   def __init__(self):
...     pass
...
 >>> b= B()
 >>> type(A)
<type 'type'>
 >>> type(a)
<class '__main__.A'>
 >>> type(B)
<type 'classobj'>
 >>> type(b)
<type 'instance'>
 >>>

I hope that this helps.

Colin W.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to