Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python private

def _private(self):
 # this class function is now private
Comment

python private method

# Python program to 
# demonstrate private methods
  
# Creating a Base class 
class Base: 
  
    # Declaring public method
    def fun(self):
        print("Public method")
  
    # Declaring private method
    def __fun(self):
        print("Private method")
  
# Creating a derived class 
class Derived(Base): 
    def __init__(self): 
          
        # Calling constructor of 
        # Base class 
        Base.__init__(self) 
          
    def call_public(self):
          
        # Calling public method of base class
        print("
Inside derived class")
        self.fun()
          
    def call_private(self):
          
        # Calling private method of base class
        self.__fun()
  
# Driver code 
obj1 = Base()
  
# Calling public method
obj1.fun()
  
obj2 = Derived()
obj2.call_public()
  
# Uncommenting obj1.__fun() will 
# raise an AttributeError 
  
# Uncommenting obj2.call_private() 
# will also raise an AttributeError
Comment

PREVIOUS NEXT
Code Example
Python :: dataframe to pandas 
Python :: append extend python 
Python :: python yeild 
Python :: gráfico barras python 
Python :: print whole list python 
Python :: flask authentication user without database 
Python :: how can i remove random symbols in a dataframe in Pandas 
Python :: np.reshape() 
Python :: how to clear dictionary in python 
Python :: count occurrences of character in string python using dictionary 
Python :: typing multiple types 
Python :: how to learn python 
Python :: subtract list from list python 
Python :: concatenate list of strings python 
Python :: how to use query_params in get_object djangorestframework 
Python :: lamda python 
Python :: length of list python 
Python :: python help 
Python :: tkinter copy paste 
Python :: how to download packages using pip 
Python :: adding one element in dictionary python 
Python :: encrypt password with sha512 + python 
Python :: how to install arcade in python 
Python :: python cv2 canny overlay on image 
Python :: how to get the max of a list in python 
Python :: append to pythonpath 
Python :: how to replace an element of a list using list comprehension 
Python :: how to import and use keyboard with pygame 
Python :: python gui 
Python :: how to capitalize first letter in python in list using list comprehension 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =