Hi, What are global, protected and private attributes in Python
Python does not have “public”, “protected” and/or “private” attributes.
(Just) by convention one uses attribute names without a leading _ for “public” attributes and attribute names with a _ for “private” attributes. Do not use attribute names with two leading _ as they might be reserved.
If you want, you can add the public-protected-private-functionality to Python by using the “property” keyword.
For a better understanding, you could have a look at:
there, the property and getter / setter mechanism is explained in detail.
Have Fun, Dominik
PS: by the way, the “global” keyword exists:
exampleVar = 2 def exampleFct(): globals exampleVar print( exampleVar )
prints 2 when calling the function exampleVar.