Comparison of Windows Azure queues with service bus queues

Source: Internet
Author: User
Tags class definition

6.5.1Multiple Inheritance

Python also supports multiple forms of inheritance. A class that can inherit multiple base classes is defined as follows:

Class Derivedclassname (Base1, Base2, BASE3):

<statement-1>

.

.

.

<statement-N>

In most cases, in the simplest case, you can think of a property query inherited from a parent class as being followed by depth first, from left to right.

Instead of executing two times in the same class that repeats at the same level. Therefore, if a property is not found in the derived class, it will first be in the base class of Base1 and then base1 , if it is not found there, it will be in base2 Search, and so on.

In fact, it's a little bit more complicated than what I just said. The order of the methods is changed dynamically in order to invoke super () together . This approach is very well known in some languages that support multiple inheritance because of the invocation of the next method. And more powerful than super calls in single-inheritance languages .

Dynamic ordering is necessary because all cases in multiple inheritance show at least one diamond relationship. (Starting with the lowest class, there is at least one parent class that can be accessed through multiple paths). For example, all classes inherit object, so that each case of multiple inheritance provides at least one path to object. to ensure that at least one method accesses the base class, the dynamic algorithm linearized the search order in a special way. This approach is to ensure that each class is left-to-right in order, with each parent class only once, and that is unchanged. (That is, inheriting a class does not have a priority for its parent), in short, these properties make it possible to design reliable and extensible classes using multiple inheritance. For more information, please refer to:

6.6Private Variables

There is no "private" variable that cannot be accessed inside the object except in python . However, most python code follows a rule: names prefixed by an underscore are considered to be non-public portions of the API. It can be thought of as a detail implementation and change without notice.

Because there is a legitimate use case for private members of the class (that is, to avoid conflicting names defined in the subclass), there is limited support for this mechanism. This mechanism is called the name transformation. _spam any identifier in the form (at least two underscores at the beginning, up to one end of the underline) can be _classname_spam instead, here ClassName is the current class name. As long as this transformation is in the class definition, this syntax location that does not involve identifiers can be handled.

Name transformation is important for subclasses to overload methods without affecting the parent class method. For example:


This transformation rule was originally designed to avoid collisions, and is still possible if the strong intention is to access or modify a variable that is considered private. In some special cases, this approach is more useful. For example, a debugger.

Note passed to exec () eval () global Global variables are similar in effect. Its role is limited to code that compiles bytecode together. The same restrictions apply to getattr () settattr () and delattr () function, and direct reference _dict_

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.