I have below datamemebers in the class and method that overload with same data members
What i am looking forward is to validate the name of members from class against the overloaded members
class Payload:
data_members=['id','name','acccount']
def __init__(self):
self.id=''
self.name=''
self.account=''
def add_data(self, id=None,name=None, account=None):
print(self.data_members)
overload_members=[id,name,account]
## what i am looking for is
for varibale1_name in self.data_members:
for variable_name2 in overload_members:
if varibale1_name==variable_name2:
print("varibale1_name and variable_name2 are same, printing same variable name:",varibale1_name, variable_name2)
else:
print("varibale1_name and variable_name2 are not same, printing non matched variables: ",varibale1_name, variable_name2)
id=1
name='Jakson'
account=123
obj= Payload
obj.add_data(id,name,account)
so the out put should like this
#Expected
varibale1_name and variable_name2 are same, printing same variable name: id,name,account
if overload with different variable name against datamembers
for eg:
obj.add_data(id,name,age)
#output is
varibale1_name and variable_name2 are not same, printing non matched variables: variable name :age
so the expected result should return the 'variable name' not the value of variables
is there any optimized way to achieve in python?
Appreciated for the help..!
Thanks