Metaclasses and new-style classes

jepler at unpythonic.net jepler at unpythonic.net
Sun Aug 7 20:07:50 EDT 2005


This may be a limitation Zope imposes.

I wrote this program:
#-----------------------------------------------------------------------
class M(type):
	def __new__(*args):
		print "new M", args

class T(object):
	__metaclass__ = M
#-----------------------------------------------------------------------

Running it prints
new M (<class '__main__.M'>, 'T', (<type 'object'>,),
	{'__module__': '__main__', '__metaclass__': <class '__main__.M'>})
... so you can see that the __metaclass__ mechanism works just fine with
new-style objects in plain Python.

Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20050807/32e008cd/attachment.sig>


More information about the Python-list mailing list