Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python access modifiers

# In python access modifying can be done by prefixing the underscore character '_' to the variable name.

# Prefixing no underscores makes the variable public.
# Prefixing 1 underscore makes the variable protected.
# Prefixing 2 underscores makes the variable private.

# In the following example, name is public, __make is private, _model is protected.
class Car:
    def __init__(self):
        print("Engine started")
        self.__make = "toyota"
        self._model = 1999
        self.name = "corolla"
Comment

PREVIOUS NEXT
Code Example
Python :: axis labels python 
Python :: eval function in python 
Python :: map to list python 
Python :: print multiplication table python 
Python :: python while 
Python :: divide all values in array python 
Python :: python generator expression 
Python :: liste compréhension python 
Python :: beautifulsoup getting data from a website 
Python :: python for loop index 
Python :: Update All Python Packages On Windows 
Python :: how to kill somene 
Python :: pandas access multiindex column 
Python :: sort dict of dicts by key 
Python :: python change function of object 
Python :: The datetime and django.utils.timezone modules are available, so you can do e.g. timezone.now 
Python :: python find if strings are anagrams 
Python :: Local to ISO 8601: 
Python :: create gui python 
Python :: flask app with spark 
Python :: identity matrix python 
Python :: pyautogui doc 
Python :: float64 python 
Python :: python sort descending 
Python :: close a file python 
Python :: list in one line of text in python 
Python :: get column or row of matrix array numpy python 
Python :: pdf to string python 
Python :: python empty dataframe 
Python :: include in flask 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =