Python Forum
Modifying Class File/ Name-Mangling
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Modifying Class File/ Name-Mangling
#4
You had some questions included in the main.py file.
(Jun-09-2021, 11:35 PM)CWillis105 Wrote:
myCustomer.Email = "THIS IS A BAD EMAIL ADDRESS" #WORKS
Yes it works. But it should not work, that is the assignment. So replace "Email" with "__Email" in the Customer.py file as Griboullis suggested.

(Jun-09-2021, 11:35 PM)CWillis105 Wrote:
myCustomer.AccountNumber = "BAD Account Number" #Doesnt Work...OR DOES IT ?
This will work in the sense it gives no error. It adds a name "AccountNumber", not to the class but to the object instance "myCustomer". But this name will not interfere with "__AccountNumber".

(Jun-09-2021, 11:35 PM)CWillis105 Wrote:
print(myCustomer.getAccountNumber()) #OLD Account Number still in tact
Right. The method "getAccountNumber()" uses "__AccountNumber", not the newly added "AccountNumber".

I hope this helps you in understanding what is happening. Don't forget to read the link of Jeffsummers.
Reply


Messages In This Thread
Modifying Class File/ Name-Mangling - by CWillis105 - Jun-09-2021, 11:35 PM
RE: Modifying Class File/ Name-Mangling - by ibreeden - Jun-11-2021, 07:56 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020