<div dir="ltr">Hi,<div><br></div><div>In various Python libraries and projects, I have seen that Foo.bar = 10</div><div>is the preferred convention, since as you mentioned, there are no private/protected</div><div>keywords in Python.</div><div><br></div><div>You may want to look at the Python attrs library, which offers some interesting</div><div>ways to use classes with attributions:</div><div><br></div><div><a href="https://glyph.twistedmatrix.com/2016/08/attrs.html">https://glyph.twistedmatrix.com/2016/08/attrs.html</a><br></div><div><a href="https://attrs.readthedocs.io">https://attrs.readthedocs.io</a><br></div><div><br></div><div>--</div><div>Craig<br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 11, 2016 at 2:29 AM, Braun Brelin <span dir="ltr"><<a href="mailto:bbrelin@gmail.com" target="_blank">bbrelin@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hello all,<div><br></div><div>I just wanted to get the list's opinion on something. </div><div><br></div><div>Since Python doesn't really have the concept of private and protected</div><div>attribute access protections a la Java or C++ (Yes, I know you can use</div><div>the __ and _ prefixes to declare something private or protected in</div><div>Python, but that really only does name-mangling on the attribute name</div><div>rather than explicitly disallow access to the attribute from outside the class), is it better to still access the attribute directly a la </div><div>Foo.bar = 10 or use a setter/getter approach like Foo.setBar(10)?<br></div><div>It seems to me that option one is better, especially if I can use a descriptor with the attribute. </div><div><br></div><div>Any thoughts?</div><div><br></div><div>Thanks,</div><div><br></div><div>Braun Brelin</div></div></blockquote></div></div></div></div>