کلاس در پایتون + هرآنچه که باید در مورد Class در پایتون بدانید

				
					•	class TrafficLight:
•	    '''This is an updated traffic light class'''
•	
•	    # Class variable
•	    traffic_light_address = 'NYC_Cranberry_Hicks'
•	
•	    def __init__(self, color):
•	
•	        # Instance variable assigned inside the class constructor
•	        self.color = color
•	
•	    def action(self):
•	        if self.color=='red':
•	
•	            # Instance variable assigned inside a class method
•	            self.next_color = 'yellow'
•	            print('Stop & wait')
•	        elif self.color=='yellow':
•	            self.next_color = 'green'
•	            print('Prepare to stop')
•	        elif self.color=='green':
•	            self.next_color = 'red'
•	            print('Go')
•	        else:
•	            self.next_color = 'Brandy'
•	            print('Stop drinking ')
•	
•	# Creating class objects
•	for c in ['red', 'yellow', 'green', 'fuchsia']:
•	    c = TrafficLight(c)
•	    print(c.traffic_light_address)
•	    print(c.color)
•	    c.action()
•	    print(c.next_color)
•	    print('\n')