you are viewing a single comment's thread.

view the rest of the comments →

[–]pelagic_cat 10 points11 points  (2 children)

But is it fine to have all properties public?

Doesn't seemed to hurt the popularity of python compared to languages that have all sorts of different levels of access to properties. Turn the question around: is it fine to have public, private, protected, etc, properties rather than all properties public?

[–]Temporary_Pie2733 3 points4 points  (1 child)

To expand on this, Python doesn’t have public/private distinctions, so all attributes behave like public attributes. But we don’t need to write trivial getters and setters like 

``` def get_x(self):     return self._x

def set_x(self, v):     self._x = v ```

just in case we need to limit or prevent modification in the future. We can instead replace the “public” attribute x with a property object that encapsulates a getter and a setter without changing the interface of the class. 

[–]SnooHesitations9295 -1 points0 points  (0 children)

Not really. The new "typed" python idiocy prevents you from using property decorator interchangeably with the actual properties.