python--object-oriented programming for multi-inheritance, combinatorial application, development software specification

Source: Internet
Author: User

Review:

Inheritance: Is the relationship between classes and classes, and what is a relationship of what

The purpose of inheritance is to solve code reuse problems and reduce code redundancy

Inheritance is to inherit the attributes of the parent class to the subclass.

Derivation is a subclass that derives its own new property

classteacher:def __init__ (self,name,age,sex,salary,level): Self.name=name Self.age=Age Self.sex=Sex self.salary=Salary Self.level=Level def walk (self): print ('%s is walking'%self.name) def teach (self): print ('%s is teaching'%self.name) def tell_info (self): print (" "----------%s Info--------NAME:%s Age:%s SEX:%s SAL:%s Level:%s" "% (self.name,self.name,self.age,self.sex,self.salary,self.level))# #classdate:def __init__ (self,year,mon,day): Self.year=Year Self.mon=Mon self.day=Day def Tell_birth (self): print ('%s-%s-%s'% (Self.year,self.mon,self.day))

Combination of applications:

Further optimization:

Serialization:

Deserialization:

deserialization must be based on the class in memory

Bin folder generally put executable file, conf folder generally put configuration file, DB folder general method data file, and log directory, lib directory (usually store common gadgets)

The main function provides a menu where the user can choose to work today: teachers, students, courses three classes to implement the course selection system

python--Object-oriented programming for multi-inheritance, combinatorial applications, development of software specifications

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.