Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python non public method

>>> class MyClass:
...     def myPublicMethod(self):
...             print 'public method'
...     def __myPrivateMethod(self):
...             print 'this is private!!'
... 
>>> obj = MyClass()
>>> obj.myPublicMethod()
public method
>>> obj.__myPrivateMethod()
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: MyClass instance has no attribute '__myPrivateMethod'
>>> dir(obj)
['_MyClass__myPrivateMethod', '__doc__', '__module__', 'myPublicMethod']
>>> obj._MyClass__myPrivateMethod()
this is private!!
Comment

PREVIOUS NEXT
Code Example
Python :: list into string python 
Python :: Use Python to calculate (((1+2)*3)/4)^5 
Python :: face sentiment 
Python :: choose custom index pandas 
Python :: python list all youtube channel videos 
Python :: how to make a tuple 
Python :: how to write a table from 1 to 10 with for loop in fython in 3 lines 
Python :: how to see what variable is closest to a higher element in python 
Python :: python save console state 
Python :: prime number program in python using function 
Python :: how to loop over all dates in python 
Python :: convertir code python en java 
Python :: Django Signup urls.py 
Python :: pause and resume threads python 
Python :: how to send jobs to queue dynamically 
Python :: pandas apply return dataframe 
Python :: Free the Bunny Prisoners 
Python :: python to open .seg file 
Python :: afkastiningsgrad 
Python :: how to convert array value to integer in python 
Python :: flask new response style with `make_response` 
Python :: tensorflow tf.constant 
Python :: dataframe passed by reference or value 
Python :: skip security check selenium linkedin python 
Python :: how to take multiple integer input in python 
Python :: python check if dictionary empty 
Python :: convert html to python 
Python :: how to get max id in mongodb python 
Python :: sns countplot show only largest 
Python :: imshow show nan as black 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =