Answers for "protected vs private python"

7

python protected attributes

class example:
  def __init__(self):
    self._variable1='protected variale' 
    self.__variable2='private variable'
    self.variable3='public variable'
Posted by: Guest on March-17-2020
0

protected vs private python

Protected : 
protected members of a class can be accessed by other members within 
the class and are also available to their subclasses.
Add a prefix _ (single underscore)

Private : 
The private members of a class are only accessible within the class.

 In Python, a private member can be defined by using a prefix 
  __ (double underscore).
Posted by: Guest on September-26-2021

Code answers related to "protected vs private python"

Python Answers by Framework

Browse Popular Code Answers by Language