For example, in С++ concept of a class exists only before compilation, then the compiler sticks together everything and optimizes it. In Java class is something more specific that exists even after compilation. How are classes organized in Python ?

Closed due to the fact that the issue is too common for the participants aleksandr barakin , HamSter , Denis , pavel , αλεχολυτ 11 Nov '16 at 8:50 .

Please correct the question so that it describes the specific problem with sufficient detail to determine the appropriate answer. Do not ask a few questions at once. See “How to ask a good question?” For clarification. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • one
    The essence of the question is incomprehensible. The principles of aop do not depend on the language. - Mr Fix
  • one
    Python (language) does not define how objects are represented in memory (classes are objects in Python as well as many other things). You are interested in a bit-wise representation of a class in some version of CPython (why?). For example, you can look, using ctypes, at any object as an array of bytes ( c_ubyte * sizeof(obj) ), an example for int - jfs
  • @Mr. Fixes how OOP principles are related to class representation in memory? - faoxis
  • @jfs why? Intersno with what you work ... I expected to see about your answer. - faoxis

1 answer 1

In python class is a complete object during program execution. You can change a class variable, for example. Then all instances created on the basis of this class (if they use the class variable) will use the new value.

The class definition is an executable instruction:

Class definitions, like function definitions (def statements) must be executed. (You could conceivably place a function in a statement. If

After executing such an instruction, a class object is created:

When a class definition is left normally (via the end), a class object is created.

More details can be read, for example python2 documentation .