metaclass

demand

Sometimes we need to know what properties and methods a class has. Known condition: an object of this class.

method

Use metaclass (). metaclass (object) returns the meta.class object, this class object contains all the information of the object class.

code

>> data=metaclass(C)

data = 

  class (具有属性):

                     Name: 'qubit'
              Description: ''
      DetailedDescription: ''
                   Hidden: 0
                   Sealed: 0
                 Abstract: 0
              Enumeration: 0
          ConstructOnLoad: 0
         HandleCompatible: 0
          InferiorClasses: {0×1 cell}
        ContainingPackage: [0×0 meta.package]
             PropertyList: [1×1 meta.property]
               MethodList: [2×1 meta.method]
                EventList: [0×1 meta.event]
    EnumerationMemberList: [0×1 meta.EnumeratedValue]
           SuperclassList: [0×1 meta.class]

>> data.Name

ans =

qubit

>> data.PropertyList

ans = 

  property (具有属性):

                   Name: 'type'
            Description: ''
    DetailedDescription: ''
              GetAccess: 'public'
              SetAccess: 'public'
              Dependent: 0
               Constant: 0
               Abstract: 0
              Transient: 0
                 Hidden: 0
          GetObservable: 0
          SetObservable: 0
               AbortSet: 0
            NonCopyable: 0
              GetMethod: []
              SetMethod: []
             HasDefault: 0
          DefiningClass: [1×1 meta.class]
Published 47 original articles · Like 33 · Visit 310,000+

Guess you like

Origin blog.csdn.net/kaever/article/details/77939290