Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to make a static variable in python

# static variable in this example is counter
class Employee:
    counter = 0
    def __init__(self, age, name , department , is_manager):
        self.name = name 
        self.age = age
        self .department = department
        self.is_manager = is_manager 
        Employee.counter += 1
 
PREVIOUS NEXT
Tagged: #static #variable #python
ADD COMMENT
Topic
Name
8+8 =