How to know Public, Private and Protected ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to know Public, Private and Protected ?

inside a python class if we have some functions then how to identify which is Public, Private and Protected ?

15th Jun 2017, 2:30 AM
Kaushik Roy
Kaushik Roy - avatar
3 Answers
+ 2
Variables and methods are public by default in python. In order to make a variable/method protected prefix its name with a single underscore. To make it private prefix it with a double underscore.
15th Jun 2017, 3:25 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
however, you can never guarantee that your attributes will be protected this way. Use it if you really have the need to do that
17th Jun 2017, 9:01 PM
Amaras A
Amaras A - avatar
0
ok , thanks
16th Jun 2017, 2:54 AM
Kaushik Roy
Kaushik Roy - avatar