How we can create private functions,variable in python. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How we can create private functions,variable in python.

i know in python everything is public but if someone wants to create private function,variable etc in python then how we can make it. does it is possible or not.

22nd Oct 2018, 4:36 PM
Maninder $ingh
Maninder $ingh - avatar
2 Answers
0
If you start a variable or function name with __, it will not be accessable directly via object. You can access it anyway if you go via class, but at least it doesn't 'just happen'. That's the privacy you get in Python.
22nd Oct 2018, 9:23 PM
HonFu
HonFu - avatar