Reputation: 23
there is a way to pass a value or a variable from a class to another class without having to pass through the main function
I'm using python
Upvotes: 0
Views: 962
Reputation: 35069
well, of course you can access other objects attributes in methods of a specific object. e.g:
class A(object):
def method(self, other):
other.somevar = 5
class B(object):
pass
def main():
a = A()
b = B()
b.somevar = "Hello World"
a.method(b)
print(b.somevar) # now prints '5'
Upvotes: 1