Is type object an instance or class?

Steven D'Aprano steve at REMOVEME.cybersource.com.au
Tue Feb 27 01:24:14 EST 2007


On Mon, 26 Feb 2007 18:00:00 -0800, JH wrote:

> A object should not be both a class and an instance at the same time.

Why ever not?

A meta-class is a class (or at least a class-like object) whose instances
are themselves classes. Under the hood, Python uses meta-classes
extensively. Most Python developers probably never need to use it, but if
you want your head to explode, read this:

http://www.python.org/doc/essays/metaclasses/

A couple of more gentle introductions are here:
http://www.python.org/doc/essays/metaclasses/meta-vladimir.txt
http://www.onlamp.com/pub/a/python/2003/04/17/metaclasses.html

Me, I think I'll stick to class factories.



-- 
Steven D'Aprano 





More information about the Python-list mailing list