What Is Class

Q

What Is Class in Python?

✍: FYIcenter.com

A

A class in Python is a statement block that defines a new data type.

A class can have the following elements:

  • Class name - A symbolic name that uniquely identifies this class within the context. The class name is also the new data type name.
  • Base class - An existing class from which the new class will inherit its properties and methods.
  • Properties - A collection of name and value pairs that can be associated with each objects created from this class.
  • Methods - A collection of functions that can be associated with each objects created from this class.

Here is an example of a simple class definition statement block and an object creation statement:

>>> class profile():
...    pass
...
>>> a = profile()
>>> type(a)
<class '__main__.profile'>

 

Defining and Using Class for New Data Types

⇒⇒Python Tutorials

2017-09-17, 110👍, 0💬