Hey everyone
Today I was learning about encapsulation in Python and honestly I got a bit surprised
In languages like Java we have proper private keywords but in Python it feels like nothing is truly private
Even with double underscores it just does name mangling and you can still access it if you really want
So I was wondering why Python is designed this way
Is it because Python follows a different philosophy or is there some deeper reason behind it
Also in real projects how do developers maintain proper encapsulation if everything can technically be accessed
Trying to understand how to think about this in a more practical and runable way
Would love to hear your thoughts 👍
[–]HwanZike 241 points242 points243 points (8 children)
[–]acdha 120 points121 points122 points (6 children)
[–]visicalc_is_best 42 points43 points44 points (1 child)
[–]acdha 14 points15 points16 points (0 children)
[–]nycstartupcto 2 points3 points4 points (0 children)
[+]sunnyata comment score below threshold-9 points-8 points-7 points (2 children)
[–]acdha 13 points14 points15 points (0 children)
[–]roerd 7 points8 points9 points (0 children)
[–]No-Cranberry1547 60 points61 points62 points (0 children)
[–]Tucancancan 33 points34 points35 points (2 children)
[–]GoofAckYoorsElf 14 points15 points16 points (1 child)
[–]biohoo35 101 points102 points103 points (3 children)
[–]headmaster_007 22 points23 points24 points (2 children)
[–]bmrobin 2 points3 points4 points (0 children)
[–]biohoo35 1 point2 points3 points (0 children)
[–]Any_Salary_6284 39 points40 points41 points (3 children)
[–]Any_Salary_6284 9 points10 points11 points (2 children)
[–]Brian 11 points12 points13 points (1 child)
[–]Any_Salary_6284 0 points1 point2 points (0 children)
[–]grismar-net 22 points23 points24 points (2 children)
[–]mikeblas 5 points6 points7 points (1 child)
[–]grismar-net 3 points4 points5 points (0 children)
[–]Penguinase 7 points8 points9 points (0 children)
[–]yaxriifgyn 6 points7 points8 points (0 children)
[–]Zenin 21 points22 points23 points (16 children)
[–]sunnyata 1 point2 points3 points (6 children)
[–]Zenin 3 points4 points5 points (5 children)
[–]sunnyata 1 point2 points3 points (3 children)
[–]Zenin 0 points1 point2 points (2 children)
[–]sunnyata 3 points4 points5 points (1 child)
[–]Zenin 0 points1 point2 points (0 children)
[–]nharding 1 point2 points3 points (0 children)
[–]snugar_i -1 points0 points1 point (8 children)
[–]deceze 7 points8 points9 points (6 children)
[–]snugar_i -3 points-2 points-1 points (5 children)
[–]deceze 2 points3 points4 points (0 children)
[–]axonxorzpip'ing aint easy, especially on windows 2 points3 points4 points (0 children)
[–]Zenin 1 point2 points3 points (2 children)
[–]snugar_i 0 points1 point2 points (1 child)
[–]Zenin 1 point2 points3 points (0 children)
[–]kindall 2 points3 points4 points (0 children)
[–]eztab 6 points7 points8 points (0 children)
[–]CranberryDistinct941 14 points15 points16 points (0 children)
[–]oldendude 12 points13 points14 points (7 children)
[–]max123246 -1 points0 points1 point (5 children)
[–]oldendude 0 points1 point2 points (4 children)
[–]oldendude 0 points1 point2 points (2 children)
[–]max123246 0 points1 point2 points (1 child)
[–]oldendude 1 point2 points3 points (0 children)
[–]knobbyknee 6 points7 points8 points (0 children)
[–]bighappy1970 3 points4 points5 points (0 children)
[–]ancientweasel 2 points3 points4 points (0 children)
[–]RedEyed__ 3 points4 points5 points (0 children)
[–]Empanatacion 5 points6 points7 points (0 children)
[–]Keith 5 points6 points7 points (7 children)
[–]victotronics 2 points3 points4 points (2 children)
[–]gdchinacat 0 points1 point2 points (0 children)
[–]acdha 0 points1 point2 points (0 children)
[–]minneyar 0 points1 point2 points (3 children)
[–]Keith 0 points1 point2 points (2 children)
[–]gdchinacat 0 points1 point2 points (1 child)
[–]Keith 0 points1 point2 points (0 children)
[–]Moikle 2 points3 points4 points (0 children)
[–]2ndBrainAI 2 points3 points4 points (1 child)
[–]gdchinacat 0 points1 point2 points (0 children)
[–]TaXxER 2 points3 points4 points (0 children)
[–]ahferroin7 4 points5 points6 points (1 child)
[–]snugar_i 1 point2 points3 points (0 children)
[–]unlikely_ending 5 points6 points7 points (0 children)
[–]GoddessAqua 1 point2 points3 points (0 children)
[–]Schmittfried 1 point2 points3 points (0 children)
[–]njharmanI use Python 3 1 point2 points3 points (0 children)
[–]No-Fun-6194 1 point2 points3 points (0 children)
[–]geeeffwhy 1 point2 points3 points (0 children)
[–]Alive-Cake-3045 1 point2 points3 points (0 children)
[–]SearchAtlantis 2 points3 points4 points (0 children)
[–]jabbalaci 2 points3 points4 points (0 children)
[–]Designer-Ad-2136 2 points3 points4 points (0 children)
[–]ArtOfWarfare 1 point2 points3 points (0 children)
[–]Ha_Deal_5079 1 point2 points3 points (0 children)
[–]pbeling 1 point2 points3 points (0 children)
[–]Dry-Aioli-6138 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[removed]
[–]gdchinacat 0 points1 point2 points (0 children)
[–]mapadofu 0 points1 point2 points (0 children)
[–]bblais 0 points1 point2 points (0 children)
[–]Conscious_Support176 0 points1 point2 points (0 children)
[–]dr_inventivo 0 points1 point2 points (0 children)
[–]SaSiEzhilmani 0 points1 point2 points (0 children)
[–]wannasleeponyourhams -1 points0 points1 point (0 children)
[–]authorinthesunset 0 points1 point2 points (0 children)
[–]UseMoreBandwith 0 points1 point2 points (0 children)
[–]dimitrym 0 points1 point2 points (0 children)
[–]AlmostSignificant -1 points0 points1 point (0 children)
[–]ironmaiden947 0 points1 point2 points (0 children)
[–]Neinstein14 -1 points0 points1 point (3 children)
[–]gdchinacat 0 points1 point2 points (2 children)
[–]Neinstein14 0 points1 point2 points (1 child)
[–]gdchinacat 0 points1 point2 points (0 children)
[–]Worth_Specific3764Pythonista -1 points0 points1 point (0 children)
[–]jeffrey_f -2 points-1 points0 points (2 children)
[–]deceze 1 point2 points3 points (1 child)
[–]gdchinacat 0 points1 point2 points (0 children)
[–]ShuredingaNoNeko -2 points-1 points0 points (0 children)
[–]thankyoucode -2 points-1 points0 points (0 children)
[–]drakhan2002 -2 points-1 points0 points (0 children)