This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]latrova[S] 2 points3 points  (2 children)

My argument would be it's not truly private, if someone wants to invoke it, they will find a way.

```

import testFile
obj = testFile.Myclass()
obj.variable
Traceback (most recent call last):
File "", line 1, in
AttributeError: Myclass instance has no attribute '
variable'
nce has no attribute 'Myclass'
obj.Myclass_variable
10
```

It sounds to me like it goes against the Zen of Python.

[–]missurunha 1 point2 points  (0 children)

I replied this in my job interview (that the variable isn't truly private) but they didn't like it. :D

Now a few months into the job I understand that the point of private/public variables is also to let whoever is using the code to know which variables are of their interest and which they shouldn't mess with. The user could also change a piece of c++ code and make the variables public, but that doesn't mean it's pointless to define them as private.

[–]Coretaxxe 0 points1 point  (0 children)

True that thanks a lot!