I have below code
class AccountBannk: def __init__(self,balance,holder): self.__AccountHolder=holder def Display_AccountHolder(self): print "account holder is" , self.__AccountHolder myaccount=AccountBannk(100000,"mehdiebagvand") #print myaccount.__AccountHolder #is a error myaccount.__AccountHolder="ali" print myaccount.__AccountHolder #print ali in this code AccountHolder is a private attribute
and in python we can not directly edit or print it.
if we try below code, python release a error
print myaccount.__AccountHolder but my questions are
1-why python not release error in below code
myaccount.__AccountHolder="ali" 2-I print myaccount.__AccountHolder in end_line but python not release error
and change the value of myaccount.__AccountHolder to 'ali'
aliand then callDisplay_AccountHolder().Display_AccountHolder()print out?ali, but left the "private" one intact.