Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to create class in python

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 434
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: