def determineMetaclass(bases, explicit_mc=None):
 meta = [getattr(b, '__class__', type(b)) for b in bases]
 if (explicit_mc is not None):
  meta.append(explicit_mc)
 if (len(meta) == 1):
  return meta[0]
 candidates = minimalBases(meta)
 if (not candidates):
  assert (not __python3)
  return ClassType
 elif (len(candidates) > 1):
  raise TypeError('Incompatible metatypes', bases)
 return candidates[0]

def determineMetaclass ( bases , explicit_mc = None ) : meta = [ getattr ( b , '__class__' , type ( b ) ) for b in bases ] if ( explicit_mc is not None ) : meta . append ( explicit_mc ) if ( len ( meta ) == 1 ) : return meta [ 0 ] candidates = minimalBases ( meta ) if ( not candidates ) : assert ( not __python3 ) return ClassType elif ( len ( candidates ) > 1 ) : raise TypeError ( 'Incompatible metatypes' , bases ) return candidates [ 0 ]
determine metaclass from 1+ bases and optional explicit __metaclass__ .