Jan-10-2023, 08:55 PM
(This post was last modified: Jan-10-2023, 08:56 PM by Yoriz.
Edit Reason: Added code tags
)
Hello,
I'm looking something similar like inheritance from an object (not a class). Example we have code:
Some time ago I was looking at the pointers in python, but found it cumbersome....
In other words: 1) we need to have one global variable. 2) that global variable is used by multiple objects 3) those multiple objects can set that variable to their local own value, but it should not affect other objects (they still see global variable's value).
This is what I have currently. The class copies value from other class. Required to create multiple copy commands to keep everything in sync when having multiple ports (ie when var on bridge changes)....
I'm looking something similar like inheritance from an object (not a class). Example we have code:
class bridge(): var=1 class ports(bridge): def update_var(self): self.var=99 def del_var(self): del varSo If I create object ports and delete or update var, it will have value of 1 on that port instance. This is what I want. But problem is I'm looking to initialize a bridge object FIRST then multiple ports. Those ports will not have their own var (instance of ports), but they will inherit var from bridge. But at some point var can/will be added/updated/deleted for that instance of port.
Some time ago I was looking at the pointers in python, but found it cumbersome....
In other words: 1) we need to have one global variable. 2) that global variable is used by multiple objects 3) those multiple objects can set that variable to their local own value, but it should not affect other objects (they still see global variable's value).
This is what I have currently. The class copies value from other class. Required to create multiple copy commands to keep everything in sync when having multiple ports (ie when var on bridge changes)....
class bridge(): var = 1 class port(): var = bridge.varMany thanks in advance!