What is the difference between 'type' and 'class'?

Thomas Jollans thomas at jollans.com
Mon Jun 21 18:37:57 EDT 2010


On 06/22/2010 12:11 AM, Peng Yu wrote:
> pydoc xrange says:
> 
> Help on class xrange in module __builtin__:
> 
> class xrange(object)
> 
> python_2.6.5_library.pdf says:
> 
> Objects of type xrange are similar to buffers
> 
> Are type and class synonyms? It seems that they are at least according
> to some webpages that I read. But I'm not completely sure. Could you
> let me know in case my impress is wrong?
> 

They're the same. *

-- Thomas

* In versions prior to 3.0, this is not 100% true.  In versions prior to
2.0, this is not true. **

** Python 2.x distinguishes between "old-style" and "new-style" classes.
New-style classes (those which subclass object) are types. The others
are a bit different, and exist only for backwards compatibility. Don't
use them.



More information about the Python-list mailing list