python basics - function complements and reflection

1 function checks
   issubclass () method for determining whether a parameter class type parameter class classinfo children and grandchildren.
   issubclass (subclass, superclass) returns True or False
   of the type (instantiate the object) Gets the current object is which class to create the output class name
   if isinstance (object class) examination object is an instance of class and class inheritance
2 function parameters to detect
   a parameter or class
3 getattr () for field properties, return values directly; methods for properties, which returns a reference, a direct reference () function can be performed
   getattr (obj, name [, default ]) where obj is the object name, name is object property must be a string.
  Return Value Type
  object - object. (Class module)
  name - String object properties.
  default - default return value, if the parameter is not available, when there is no corresponding attribute triggers AttributeError.
  class Student: # define classes
    DEF the __init __ (Self, name, Identity, Age = '15 '):
      the self.name name =
      self.identity = Identity
      self.age Age =
  C = Student ('. 1 ',' 23 is ',' twenty three')
  getattr (c, 'name') where a string must bear in mind, if the set a default value, then, even without the presence of a variable is not given here refers to a module class and instance
 summary we can be understood as a finder in accordance with conditions of a query to find meet the members of the
 classic scene
1 according to different numbers of menu selection method
2 except there
  hashattr (obj, name) verify the existence of
  delattr (obj, name) defaults delete objects in memory
  setattr (obj, name, default) object variable set default ,, expression object method is provided, in memory

Guess you like

Origin www.cnblogs.com/danhuangpai/p/10942037.html