|
|
|
|
|
by ModernMech
43 days ago
|
|
I dunno, as someone who doesn't program in Python, I find dunders to be very confusing. Like, how is this readable? _foo foo_ __foo _Foo__bar __foo__ foo__bar All of that is valid Python, and some of those forms mean different things depending on where they are used. |
|
Otherwise, a leading underscore indicates a private method but isn't enforced. A double leading underscore is also a private method but is "enforced" by giving it an unpredictable name. Double underscore (on both sides) means the function is digging in to python's API, like if you want to give a class some behaviour with + or = or [].
It's not trivial, and not particularly intuitive, but it's not necessarily terribly confusing.