class a(type):
def __str__(self):
return 'aaa'
def __new__(cls, name, bases, attrs):
attrs['cool']='cool!!!!'
new_class = super(a,cls).__new__(cls, name, bases, attrs)
#if 'media' not in attrs:
#new_class.media ='media'
return new_class
class b(object):
__metaclass__=a
def __str__(self):
return 'bbb'
print b
print b()['cool']#how can i print 'cool!!!!'
-
5Just in case people don't read past the title, you should try to make it reflect the rest of your question.Josh Lee– Josh Lee2010-01-19 08:15:58 +00:00Commented Jan 19, 2010 at 8:15
-
Printing Foo or Bar(en.wikipedia.org/wiki/Foobar) is cooler!Nikita Fedyashev– Nikita Fedyashev2010-01-19 09:18:21 +00:00Commented Jan 19, 2010 at 9:18
Add a comment
|