5 ms·
> However, Python does not have a real privacy model. > This is unsettling if you’re coming from a Java or C/C++ world and are expecting access modifiers It's
by jack9 8y ago
> However, Python does not have a real privacy model.
> This is unsettling if you’re coming from a Java or C/C++ world and are expecting access modifiers
It's unsettling to a lot of people, but so what? I still don't see a solid use case for where member access (not "privacy") is a good idea. Python is one of the only languages to get access modifiers right (convention), imo and I don't even like Python.
You could implement some "privacy" with a lambda closure (which gets increasingly complex), but that's one more technique that lambdas are ill-suited for.
- DonaldPShimoda 8y agoThe author makes a lot of strong statements based on their opinions. I wrote a bit about their dynamic/weak typing gaffe in another top-level comment. > lambda closure Just FYI (not intended to be mean or anything), in formal PL theory this phrasing doesn't make sense. A closure is the pairing of an anonymous function (a "lambda") with an environment. Python's "lambda" is really just a lambda --- it is not a closure. This is revealed in the common pitfall where you try to create a list comprehension using a lambda to generate interior values.
- jack9 8y agoThe idea is to create a lambda that's sole purpose is to act as a closure for member access restriction. I'm not sure how that could be misinterpreted, but here's your prize.
- DonaldPShimoda 8y agoI guess my point was that you should have just said "closure" instead of "lambda closure", since that phrasing doesn't make any sense in a formal context. Lambdas and closures are different things entirely. I really wasn't trying to be patronizing or anything; I was just trying to offer information in case you found it interesting, but I guess I missed the mark there. My apologies.
- deleted 8y ago[deleted]
- deleted 8y ago[deleted]
- bb88 8y agoEven in C/C++ privacy is silly, since at any point, any part of the program can look up any part of memory it has access to, and that would include privately defined members.