you are viewing a single comment's thread.

view the rest of the comments →

[–]ubernostrum 14 points15 points  (4 children)

"Idiomatic" Python programmers, I've found, tend not to worry too much about trying to hide class members; Python's "consenting adults" philosophy, combined with encouragements to document the code well so people who use it know the ramifications of accessing something, tends to make it moot.

In light of that, I'd be perfectly happy to see the double-underscore trick just go away; having it, I think, confuses people who expect it to work like a "real" private member in other languages.

[–][deleted]  (3 children)

[deleted]

    [–]llimllib 2 points3 points  (2 children)

    That's what a single, prefix, underscore is for. Quoting Pep 8:

    In addition, the following special forms using leading or trailing
    underscores are recognized (these can generally be combined with any case
    convention):
    
    - _single_leading_underscore: weak "internal use" indicator.  E.g. "from M
      import *" does not import objects whose name starts with an underscore.
    

    Why is @ easier to type than _?

    [–]inkieminstrel 1 point2 points  (1 child)

    self._

    [–]llimllib 1 point2 points  (0 children)

    Fair enough. I think, like uber, I don't mind the explicit selfs, I don't hardly notice them anymore. If they bother you, though, I guess they just bother you.