Hi,
Yes, the above could work even without super when having one bridge. So below is more simple. Instance adds its variable and uses local version. when deleted it will use global class variable. But problem is - how to have multiple bridges with different value? So we have port1/2/3/4 created from Bridge1 with class/"global" value of 1 and we want another Bridge with ex value 2 and other ports having that 2 global value.
Let's say scenario: We have hundreds of houses each having different internet speed: 5Mbps/100Mbps/25Mbps (so we have a class for each house). Then we have rooms/people in each house. If that person/room has a faster internet speed (lets say room1 for the house5), that room/person should not use houses internet, it should use it's own faster internet.... (use room variable rather than global house variable)
Yes, the above could work even without super when having one bridge. So below is more simple. Instance adds its variable and uses local version. when deleted it will use global class variable. But problem is - how to have multiple bridges with different value? So we have port1/2/3/4 created from Bridge1 with class/"global" value of 1 and we want another Bridge with ex value 2 and other ports having that 2 global value.
Let's say scenario: We have hundreds of houses each having different internet speed: 5Mbps/100Mbps/25Mbps (so we have a class for each house). Then we have rooms/people in each house. If that person/room has a faster internet speed (lets say room1 for the house5), that room/person should not use houses internet, it should use it's own faster internet.... (use room variable rather than global house variable)
class bridge: var = 1 class port(bridge): def update_var(self,v): self.var = v def delete_var(self): del self.var port1 = port() port2 = port() print(port1.var) print(port2.var) port2.update_var(3) print(port2.var) port2.delete_var() print(port2.var)