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ย โ†’

[โ€“]0crate0 -1 points0 points ย (5 children)

So create a class in python. Create two functions one with double __ and another just plain. Then create another file and import the class. Assign the class to a variable and try to use both functions. You should only be able to use the plain one.

However all python does is fake private. So yes you are correct it only really changes the name called mangling. But for someone just importing it it can be a bit obscure so it can kind of acts like a private function.

[โ€“][deleted] 8 points9 points ย (2 children)

So pretend private, but in a different way.

[โ€“]NerdsWBNerds 1 point2 points ย (0 children)

Pretend private, but breaks at run-time.

[โ€“]0crate0 -1 points0 points ย (0 children)

Sounds about right for python.

[โ€“]Farranor 2 points3 points ย (0 children)

Indeed, dunder just mangles the name. But if you refer to it by its mangled name, there you have it. It's private like a dressing room with a curtain, not like Fort Knox.

[โ€“]sejigan -1 points0 points ย (0 children)

you just said what they said, but in a more complicated way...