How do I pass an instance of a class to the __init__ method of another class so that I can access it's variables?
eg:
class my_class:
variable=0
variabletwo=9
a=myclass()
How do I access the "variable" field of "a" from another class? I could write something like a.variable but that would only work for an object called "a".
i want to be able to provide the name of any object of the class"my_class" so that the variable field of that object can be accessed...
This might seem confusing so I'll do my best to provide an example.
like so:
class second_class:
def __init__(self,external_variable):
when I create an instance of the "second_class" class I want to be able to pass "a" as the argument and be able to access the "variable" field of a. In this case the output should be 0 (zero).