Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Encapsulation
#1
Hi,

Was reading some articles and got this code in the multi-choice option, wanted to know what would be the put of this code?

class BaseClass:
    def __init__(self):
        self._x = 10

class DerivedClass(BaseClass):
    def __init__(self):
        BaseClass.__init__(self)
        print(self._x)

obj1 = DerivedClass()
obj2 = BaseClass()
print(obj2.x))
Thank You!
buran write Apr-27-2023, 08:04 AM:
Spam link removed
Reply


Messages In This Thread
Python Encapsulation - by codinglearner - Mar-24-2022, 12:47 PM
RE: Python Encapsulation - by deanhystad - Mar-24-2022, 07:26 PM
RE: Python Encapsulation - by DataScience - Apr-02-2024, 01:26 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Function encapsulation Oldman45 4 2,347 Jan-22-2021, 11:38 AM
Last Post: Oldman45
  Preserve Encapsulation while Displaying Information QueenSvetlana 13 7,116 Dec-07-2017, 06:13 PM
Last Post: snippsat
  Encapsulation issue iFunKtion 4 4,007 Mar-07-2017, 10:13 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

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