Interesting right?
If you read this amazing tutorial by lionaneesh, you will understand why I posted this brain-boggling code.

Edited 6 Years Ago by jcao219: n/a

class TurnIntoString(type):
    def __new__(metacls, clsN, bases, clsdict):
        return "{0} from {1}.".format(clsdict.get('msg'),
                clsN)

class MyMessage(object):
    __metaclass__ = TurnIntoString
    msg = "Hello World"

print MyMessage
print MyMessage.upper()
print type(MyMessage)
print MyMessage[::-1]

#What? MyMessage, which is obviously a
#class, is now a string?
try:
    a = MyMessage() #doesn't even behave like a class anymore
except:
    print "It's no longer a class, but a string."

Basically, a metaclass is the class of a class.
So if you want to change a class in some way,
you can do that through metaclasses.

The article starter has earned a lot of community kudos, and such articles offer a bounty for quality replies.