Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 22514

Python class -- How may I access an double underscored attribute that is added through object within a method of the class

$
0
0

In the below program is it possible to access __breadth attribute in area(self) method?

class Rectangle:    def __init__(self, L):        self.__length = L    def area(self):        return self.__length * self.__breadthb = Rectangle(10)b.__breadth = 5print(b.__dict__)print(b.area())

I have tried to access __braedth in the area(self) method but it is not possible.


Viewing all articles
Browse latest Browse all 22514

Trending Articles