0

Can you help me to access the instance variable in this python code

My question is how can i access the fname, lname, gender, address with the object of the class Saving in show_data method https://code.sololearn.com/c45L6w6PNRSn/?ref=app

17th Mar 2020, 3:44 PM
Devang H Baroliya
Devang H Baroliya - avatar
9 Answers
+ 8
Some modifications done, see attached file with this mark # <<< Be aware, that in your case all of the information like fname, lname,... are not protected, so they can be read but also modified by write. https://code.sololearn.com/cyJ0s8aHs4pj/?ref=app
17th Mar 2020, 4:45 PM
Lothar
Lothar - avatar
+ 3
When you said "access the fname, lname, gender, address ..." do you mean to modify them or to show them?
17th Mar 2020, 3:57 PM
Ipang
+ 3
I think it's better if you move the fname, lname, gender and address fields from BankInfo into BankAccount. Those fields represents a client rather than the bank itself. You can also move the interest calculation method into the BankAccount as that calculation is done based on fields of BankAccount class. Just my opinion though,
17th Mar 2020, 4:55 PM
Ipang
+ 2
https://code.sololearn.com/cN6U2isR3XNT/?ref=app 1) In this code when we create object of saving and current class why we pass class bankinfo object 2) and the method viewprofile in saving and current class how we can get Self.bankinfo.fname???
17th Mar 2020, 5:54 PM
Devang H Baroliya
Devang H Baroliya - avatar
+ 1
it's better to learn both to modify and show but first i want to learn show than to modify
17th Mar 2020, 4:23 PM
Devang H Baroliya
Devang H Baroliya - avatar
+ 1
Sir but i want to print Data with the help of savingobj how can i do ????
17th Mar 2020, 4:59 PM
Devang H Baroliya
Devang H Baroliya - avatar
+ 1
May I ask why you think you need a `Saving` class in the first place?
17th Mar 2020, 5:02 PM
Ipang
+ 1
I want to know that if i write program that have 3 class and have a multilevel inheritance in grandparent class have init method to store data Parent class have init method to store data Child class having method to show data Both parent class and grandparent class have different obj to store data How can i get that data with the help of child class obj ???
17th Mar 2020, 5:12 PM
Devang H Baroliya
Devang H Baroliya - avatar
+ 1
I'm afraid what you ask for is beyond my knowledge. Anyways, I hope someone can assist you through this 👍
17th Mar 2020, 5:16 PM
Ipang