1. Reflection2. Built-in methods__ Name __: Special method/Built-in method in classDouble Subscript Method Magic method1.__call__Instantiating an object ()---->> equivalent to executing the __call__ methodApplication: Used to view the execution process in the source code 2.__len__ for viewing the length of an objectLen (object), the __len__ method that invokes object does not execute Len () if there is no __len__ error 3.__new__------>>> Construction method__INIT__------>>> Initializat
In Python, if a method is executed in a multithreaded manner, it is simply a function object that is the first parameter of the synchronization function. However, if the function object is a static method of a class, the function object that uses the class directly will have an error. At this point, you need to construct a proxy method to implement.For example, the static class method of statistical directory size in the previous blog post, if you wan
1.class_a ()Class_b ()2.class_b using variables and functions in Class_a3. Variable class_a: class_a.num= ...function Class_b: Instantiate the class_a first (if there is initialization in class_a, then it is also initialized at this time, in order to avoid the second initialization can not write initialization in the CLASS_A as the initialization function), and then call the functionThe class_a variable used in the function called in the calling function must also be in Class_a: class_a.num= ...
" "keyword argument to%s (). Don ' t do that."% (key, CLS.__name__)) if nothasattr (CLS, key):RaiseTypeError ("%s () received an invalid keyword%r. As_view" "Only accepts arguments that is already" "attributes of the class."% (CLS.__name__, key)) defView (Request, *args, * *Kwargs): self= CLS (* *Initkwargs)ifHasattr (Self,'Get') and notHasattr (Self,'Head'): Self.head=Self.get self.request=
): + " " - defining subclasses: Students $ Properties: Study number $ method: Lectures (Print: Name + School Number + "listening class") - " " - def __init__(self, Name,age, StudentID): thePerson.__init__(self, name, age) -Self.studentid =StudentIDWuyi the defLearn (self): - PrintSelf.name + str (self.studentid) +"I 'm listening ." Wu - About if __name__=="__main__": $ - #instantiate a teacher, three students, then mock the teacher class, the teacher dismissed the
" "self.miters+=add_mitersdefprint_miters (self):Print("This car has"+ STR (self.miters) +"miles on it")#Create an instanceMy_user_car = Car ('Audi','A4',' .')Print(My_user_car.get_describe_car ()) My_user_car.update_miters (200) my_user_car.print_miters () my_user_car.increment_miters (100) my_user_car.print_miters ()The new Method Increment_miters () takes a number and adds it to Update_miters () the number of miles that have been modified, we call the method Update_miters () to pass in 200, a
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.