Type.__new__ (cls, name, bases, attrs) type (cls,xx) difference?

when beginner python, sees metaclass,
type is a metaclass when the generated "class" object is returned in the _ _ new__ method of metaclass, so what"s the difference between
return type.__new__ (cls, name, bases, attrs) and return type (cls, name, bases, attrs)?

Mar.13,2021

type.__new__ () calls the class method of type class _ _ new__ or static method _ _ new__ .
type () is to create a new type instance using the _ _ init__ () method of type or to call the static _ _ call__ () method or class method of the type class _ call__ () (typically, to find the type of an object type ("Hello") )


type () accepts only one or three parameters, and one parameter returns the type, of the object. The three parameters generally return a new type class of type < class' type' >
type.__new__ (), creates an instance of the type class of type class'_ main__.cls',

Menu