python protected attributes
class example:
def __init__(self):
self._variable1='protected variale'
self.__variable2='private variable'
self.variable3='public variable'
python protected attributes
class example:
def __init__(self):
self._variable1='protected variale'
self.__variable2='private variable'
self.variable3='public variable'
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).
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us