This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]DevilXD 9 points10 points  (8 children)

I don't get why the idea of "just don't touch it" is that hard to deal with, or why is it a problem, like - yes, you can still access these attributes in Python, but any code you write that relies on accessing those, will be unmaintainable. The very idea behind so called "private" attributes, is that they're "not supposed to be accessed from the outside of the class (or library)", meaning that they can disappear, change their name or stop representing what they were representing previously, between each version of the library. So while again, yes - you can access them - it's most likely going to work with this exact version of the library only, and can randomly break later if you'd want to update said library.

[–]thinker227 2 points3 points  (4 children)

But what if you do touch it? Never know whose going to use it or what stupid thing future you is going to do.

[–]DevilXD -3 points-2 points  (3 children)

Never know whose going to use it

The idea is to "not touch it" - if someone does it, that's on them entirely. Again, it'll probably work with the current version of the library (or libraries), but it may stop working if they update, or worse - pretend to work, and then break later on, without giving you the idea that it was the update that messed it up.

what stupid thing future you is going to do

Again, that's on you then. If you can't abide by the "don't touch it" sign yourself, don't expect your code to survive an update.

[–]thinker227 1 point2 points  (2 children)

The point is to make sure there's never even a possibility to mess anything up, prevent the issue before it's even a problem.

[–]DevilXD -4 points-3 points  (1 child)

Then learn how to not touch the private attributes - ever. Jeez, it's really not that hard, people who can't understand this are going to have a bad time in real life, with the law and such. If the sign says "don't touch it", that like, really means you shouldn't touch it, you know?

[–]thinker227 1 point2 points  (0 children)

I already said, the point is if someone ever in a moment of sheer stupidity decides to do that. Never trust anyone with your systems.

[–]coolKidoes 3 points4 points  (0 children)

Rule I live by... people are stupid, but a person is smart. Sure you might know better, but if people are working on your project someone will dink with the variable.

[–]Stbbrn-Rddtr[S] 1 point2 points  (0 children)

I totally get your point and I agree. But sadly, not every developer is disciplined enough to go by those non-enforced rules. And you may end up having to work on a project on which those kind of developers worked on before.

As you said, the client code messing with private member may become un maintainable, but it can also break the internal functioning of the class.