3 ms·
I am pro-snake myself, but those that use double underscores, especially in a meaningful way, are drilling holes in our boat.
by brookst 4y ago
I am pro-snake myself, but those that use double underscores, especially in a meaningful way, are drilling holes in our boat.
- spookthesunset 4y agoWhat is a double underscore? hello__world?
- jayknight 4y agoYep, or "dunder" as it's often called in the python world.
- eddsh1994 4y ago__special_functions__ __privateish_variable Etc, in the land of Python
- goodoldneon 4y agoI wish Python enforced private attributes. I once worked in a codebase where this was roughly true: _usually_private_but_ok_to_access_if_you_are_knowledgeable __private_unless_you_need_an_escape_hatch ___absolutely_private_except_for_a_few_times
- brookst 4y agoI mean doesn’t it make you want to make ___________super_ultra_private, with an accessor that corrupts the filesystem and hangs if you so much as look at it?
- goodoldneon 4y agoThat sounds good, but we might need a class attribute that disables filesystem corruption in case we need to access `___________super_ultra_private` somewhere
- stnmtn 4y agoI don't hate leading underscores on _private_function or _class variable, in fact I think it's a great way to semantically signal intent The double underscore for __super_private_function doesn't make much sense to me though. I can't see a reason why this shouldn't just be a single underscore, especially when __double_underscore__ signals very important python internals
- clawlor 4y agoThe leading double underscore functions differently from a leading single underscore in this case: > Any identifier of the form __spam (at least two leading underscores, at most one trailing underscore) is textually replaced with _classname__spam, where classname is the current class name with leading underscore(s) stripped. See https://docs.python.org/3/tutorial/classes.html#private-variables https://docs.python.org/3/tutorial/classes.html#private-vari...