News for hackers. Stuff that matters.
Re:Public/protected/private is an unnecessary feature by NeutralForest on Thursday June 19, 2025 @04:44PM (#44322380)
I see what you mean what I wouldn't really qualify name mangling as private members, you're discouraged to access them but you can access them all the same.
Re:Public/protected/private is an unnecessary feature by jjice on Thursday June 19, 2025 @05:12PM (#44322578)
I'd consider it the same, personally. It's a social contract that you can absolutely break if you want, just with a bit of work.

Less work in Python than it is Java, but there are ways to get to them in Java, or hell, just modify the source and change it directly. By doing that, you're doing something the developer didn't intend and you shouldn't be surprised if it doesn't work at some point in the future. Same as I'd expect in the Python case.

Re:Public/protected/private is an unnecessary feature by NeutralForest on Thursday June 19, 2025 @05:30PM (#44322706)
Sure, I think the bar to modify is higher in Java for example but I can't really find fault in what you're saying because I'd never unknowingly modify a member with double underscores in Python.
Re:Public/protected/private is an unnecessary feature by throwaway2037 on Friday June 20, 2025 @01:00AM (#44324873)

    > but you can access them all the same
Can't you do the same in C++ using struct offsets and reinterpret_cast<>? I'm not sure what you are saying here.
Re:Public/protected/private is an unnecessary feature by NeutralForest on Friday June 20, 2025 @03:34AM (#44325494)
I'm not familiar with C++ enough to know about circumventing `private` but in Python you can access "private" members just like any other "public" ones, with the dot notation. There's no specific enforcement at the language level, no error will be thrown.
Re:Public/protected/private is an unnecessary feature by colejohnson66 on Friday June 20, 2025 @08:29AM (#44327049)
Something something undefined behavior