Firstly, sorry if that name is horribly misleading. I'm not actually sure exactly what I would call what I'm trying to do. By the same token, my searches on the topic may have been lacking, so I apologise if this is something that I really should have been able to look up.
What I'm trying to do is to create a function that uses variables from objects in two separate classes, and then changes a variable for an object in the latter class.
class Type_1:
def __init__(self, a, b, c, d, e):
self.variable1 = a
self.variable2 = b
self.variable3 = c
self.variable4 = d
self.variable5 = e
def push(target):
self.variable1 += 5
target.variable2 -= int(self.variable5 - target.variable3)
class Type_2:
def __init__(self, a, b, c, d, e):
self.variable1 = a
self.variable2 = b
self.variable3 = c
self.variable4 = d
self.variable5 = e
The plan was to find a way to make the push function in Type_1 able to recognise an object in any class, provided it has the necessary variables, as its target and thus affect said object but my way of doing so doesn't work.
Edit: The issue is that when I use the push function, python always specifically looks for variables that belong to a class called target. It doesn't look for a class according to what I entered i.e.
push(John)
would still look to try and try and edit target.variable2 when I'm trying to make it edit John.variable2.
Edit2: This problem has now been solved thanks to mata and Mikhail Karavashkin.