News for hackers. Stuff that matters.
Re:Metaclasses in Python by lang on Friday December 16, 2011 @06:46AM (#3360410)
I find metaclasses philosophically unsound. If one introduces metaclasses, what about meta-metaclasses, meta-meta-metaclasses. In this regard Self's prototypical oop seems more coherent - there are only objects. Even object/class duality looks philosophically more attractive than object/class/metaclass trio.
Re:Metaclasses in Python by lloeki on Friday December 16, 2011 @09:17AM (#3360740)
meta is all relative and means 'beyond'. A metaclass being a class, it can itself have a metaclass, and so on, and they are all only objects, where the author's following excerpt embodies:

    MyClass = MetaClass()
    MyObject = MyClass()
Those two code blocks are effectively equivalent:

    class Quux(type):
        #__metaclass__ = type is implicit
        pass
    
    class Qux(object):
        __metaclass__ = Quux
        pass
and:

    Quux = type('Quux', (type,), {})
    Qux = Quux('Qux', (object,), {})
the __metaclass__ attribute merely puts in words what's the callable being called when the keyword class gets parsed and subsequently handled in the current namespace.

This class/object unification is one of a bunch of unifications I find extremely satisfying when thinking about how Python ticks.