in python xlist the desired metaclass as keyword argument in the class headerclass spam(metaclass=meta) version (onlyinheritance superclasses can be listed in the header as well in the followingfor examplethe new class spam inherits from superclass eggsbut is also an instance of and is created by metaclass metaclass spam(eggsmetaclass=meta)normal supers okmust list first in this formsuperclasses must be listed before the metaclassin effectthe ordering rules used for keyword arguments in function calls apply here declaration in we can get the same effect in python xbut we must specify the metaclass differently --using class attribute instead of keyword argumentclass spam(object)__metaclass__ meta version (only)object optionalclass spam(eggsobject)__metaclass__ meta normal supers okobject suggested technicallysome classes in do not have to derive from object explicitly to make use of metaclasses the generalized metaclass dispatch mechanism was added at the same time as new-style classesbut is not itself bound to them it doeshoweverproduce them--in the presence of __metaclass__ declaration makes the resulting class new-style automaticallyadding object to its __bases__ sequence in the absence of this declaration simply uses the classic class creator as the metaclass default because of thissome classes in require only the __metaclass__ attribute on the other handnotice that metaclasses imply that your class will be new-style in even without an explicit object they'll behave somewhat differently as outlined in and as we'll see ahead may require that they or their superclasses derive from object explicitlybecause new-style class cannot have only classic superclasses in this context given thisderiving from object doesn' hurt as sort of warning about the class' natureand may be required to avoid potential problems also in xa module level __metaclass__ global variable is available to link all classes in the module to metaclass this is no longer supported in xas it was intended as temporary measure to make it easier to default to new-style classes without deriving every class from object python also ignores the class attributeand the keyword form is syntax error in xso there is no simple portability route apart from differing syntaxthoughmetaclass declaration in and has the same effectwhich we turn to next declaring metaclasses