Ive looked up the code for how to create a class in python but I dont quite understand some parts of it. Here are two differrent examples I found:
######################
class ClassName:
<statement-1>
.
.
.
<statement-N>
######################
class 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
########################
My questions are:
- in example 1, what does <statement-N> mean? is it just part of the example and represents any statement?
- in the second example, what does “def init(self, name, salary):” mean? is it necessary for the creation of the class?