In python class statement creates a new class definition and The class has a documentation string which can be accessed via ClassName.__doc__. The class_suite consists of all the component statements defining class members, data attributes and functions use keyword class to create class .
use this syntax show in given below,
class ClassName:
'Optional class documentation string'
class_suite
Example:
ass Employee:
'Common base class for all employees'
empCount = 0
def __init__(self, name, salary):
self.name = name
self.salary = salary
Employee.empCount += 1
def displayCount(self):
print "Total Employee %d" % Employee.empCount
def displayEmployee(self):
print "Name : ", self.name, ", Salary: ", self.salary
0 Comment(s)