Skip to main content
16 events
when toggle format what by license comment
Apr 12, 2017 at 5:02 comment added mrr There are lots of questions like 'why doesn't Python have access modifiers', 'what does __attr mean in Python?', 'what is the difference between _attr and __attr in Python?', 'how do I make a method private in Python?', etc.
Apr 11, 2017 at 23:26 comment added Trevor Boyd Smith @MilesRout I spent a while searching for this question and was unable to find any good questions on stackexchange and so if you really do have a dozen links then please do share. When I did my searching, I was expecting to find questions with at least 300+ upvotes but instead I didn't find any good questions on stackoverflow or stackexchange.
Apr 11, 2017 at 23:23 comment added Trevor Boyd Smith @MilesRout additionaly may I remind you: "There are many ways to ask the same question, and a user might not be able to find the answer if they're asking it a different way." and "duplication is not necessarily bad. Quite the contrary — some duplication is desirable. There’s often benefit to having multiple subtle variants of a question around, as people tend to ask and search using completely different words"
Apr 11, 2017 at 23:16 comment added Trevor Boyd Smith @MilesRout your answer is completely nonconstructive and unhelpful. you say that this question has been asked a dozen times but you provide zero links to the supposed "duplicate questions". If you were being constructive/helpful you would have posted the dozen links. If you were being constructive you would additionally vote to close this question as a duplicate (and carefully chosen the best question of the dozen as the one that this one duplicates).
Apr 11, 2017 at 22:41 comment added mrr -1. This question has been asked a dozen times before. Python doesn't have access modifiers and you shouldn't try to emulate them
Apr 7, 2017 at 10:39 answer added bgusach timeline score: 5
Apr 6, 2017 at 20:24 history tweeted twitter.com/StackSoftEng/status/850081793697083394
Apr 6, 2017 at 17:06 comment added Vincent Savard @TrevorBoydSmith You asked for a canonical answer. I can only provide an answer based on my own experience, and as you surely know, if this is what you're actually looking for, your question is primarily opinion-based and should be closed.
Apr 6, 2017 at 16:53 comment added Trevor Boyd Smith @VincentSavard and jonrsharpe instead of offering partial answers in the comments, could you please submit an answer? The links I provided talk about how Answers are preferred on all stackexchange websites.
Apr 6, 2017 at 13:27 comment added Vincent Savard @jonrsharpe I still prefer to use a property, since it has the side effect of disallowing setting the attribute unless explicitly specified. I don't consider properties "complicated accessor/mutator methods".
Apr 6, 2017 at 13:22 comment added jonrsharpe @VincentSavard hopefully not in violation of "For simple public data attributes, it is best to expose just the attribute name, without complicated accessor/mutator methods"!
Apr 6, 2017 at 13:16 comment added jonrsharpe Have you read the style guide? The naming section covers all of this. Also we're all consenting adults here and everything is public really (foo.foo, foo._bar and foo.__Foo_baz).
Apr 6, 2017 at 12:19 comment added Vincent Savard I'm not sure if there is a canonical answer, but as a rule of thumb, I prefix every attribute by an underscore, and I expose them using properties if necessary. I also believe it's a bit misleading to talk about protected and private in Python's context because I don't think it relates very well to the same concept in, say, Java.
Apr 5, 2017 at 23:33 history edited Trevor Boyd Smith CC BY-SA 3.0
added 51 characters in body
Apr 5, 2017 at 23:29 comment added Trevor Boyd Smith I'm sure there are better ways to word "only make public only what is necessary, make protected only what is necessary" but I wanted to get this question out there.
Apr 5, 2017 at 23:26 history asked Trevor Boyd Smith CC BY-SA 3.0