Been reading up on #Python lately. I know that classes in Python "doesn't support" private values, but could this functionality not be implemented with closures?
Edit: typo
Edit: typo
Meghana :bongoCat: likes this.
Meghana :bongoCat: likes this.
Jonathan Lamothe
Content warning: boring nerd stuff (example code)
Wouldn't this effectively make
count
into a private variable (granted, one that *couldn't* be inherited)?There's probably a better way of writing it too.
Zerody likes this.
Gabriel Pettier
•Content warning: boring nerd stuff (example code)
edit: though even in java or c++, you can do horrible stuff to access stuff that were declared "private", it's also a bad idea, but since people use libraries that sometime made stupid decisions, they will sometimes do it, because they can't find another way.
Gabriel Pettier
•Jonathan Lamothe
Gabriel Pettier
•Jonathan Lamothe
At the very least, it's fair to say that there is no official way.
Gabriel Pettier likes this.
Maurice LéDuck
•Jonathan Lamothe
dn
•Jonathan Lamothe
That said, it was more of a hypothetical question.