what is classes in python
Classes in Python
  • Classes means of a bundling data and functionality together. Creating a new class makes a new object, enabling new instances of that type to be made.
  • Each class instance can have attributes attached to it for maintaining its state. Class instances can also have methods (defined by its class) for modifying its state.
  • Compared with other programming languages, Python’s class mechanism includes classes with a minimum of new syntax and semantics. It is a blend of the class mechanisms that are found in C++ and Modula-3.
  • In Python, the class inheritance mechanism allows multiple base classes, a derived class will override some methods of its base class, and the method will call a method of a base class with the same name.
  • Objects can contain random amounts and kinds of data. It is true for modules, classes split of the dynamic nature of Python: they are created at runtime, and then can be changed further after making.

Syntax:

class ClassName:
'Optional class documentation string'
class_suite

The class has a documentation string, which can be accessed via ClassName.__doc__.

The class_suite consists of all the component statement defining class members, data attributes and functions.

Categorized in:

Tagged in:

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,