Re: Will python never intend to support private, protected and public?

Discussion in 'Python' started by Steve Holden, Sep 28, 2005.

  1. Steve Holden

    Steve Holden Guest

    could ildg wrote:
    > Python is wonderful except that it has no real private and protected
    > properties and methods.
    > Every py object has dict so that you can easily find what fields and
    > methods an obj has,
    > this is very convenient, but because of this, py is very hard to support
    > real private and
    > protected?
    > If private and protected is supported, python will be perfect.
    >

    You only say that because you assume private and protected give you a
    security that they actually don't. They certainly make it more difficult
    to *spot* the security errors.

    regards
    Steve
    --
    Steve Holden +44 150 684 7255 +1 800 494 3119
    Holden Web LLC www.holdenweb.com
    PyCon TX 2006 www.pycon.org
    Steve Holden, Sep 28, 2005
    #1
    1. Advertising

  2. Steve Holden

    Kay Schluehr Guest

    Steve Holden wrote:
    > could ildg wrote:
    > > Python is wonderful except that it has no real private and protected
    > > properties and methods.
    > > Every py object has dict so that you can easily find what fields and
    > > methods an obj has,
    > > this is very convenient, but because of this, py is very hard to support
    > > real private and
    > > protected?
    > > If private and protected is supported, python will be perfect.
    > >

    > You only say that because you assume private and protected give you a
    > security that they actually don't. They certainly make it more difficult
    > to *spot* the security errors.


    Honestly I like to use private/protect/public modifiers in C++ for the
    sake of code documentation. I like to know which attributes are
    dedicated to be known by other objects, which ones are for internal use
    only and which ones should be at least publicly accessible within a
    class hierarchy. This helps structuring code in the large and spotting
    attention. Code becomes easier accessible. But if we have Sunday or I
    get asked by serious programmers I also know the right technical
    answers about protection rights, security etc.

    Kay
    Kay Schluehr, Sep 29, 2005
    #2
    1. Advertising

  3. Kay Schluehr <> wrote:

    > Honestly I like to use private/protect/public modifiers in C++ for the
    > sake of code documentation. I like to know which attributes are
    > dedicated to be known by other objects, which ones are for internal use
    > only and which ones should be at least publicly accessible within a
    > class hierarchy. This helps structuring code in the large and spotting
    > attention. Code becomes easier accessible. But if we have Sunday or I


    This advisory role is played in Python by naming conventions. Start
    attribute names with a single underscore to suggest "private but may be
    easily overridden by subclasses" (roughly the equivalent of "protected";
    Stroustrup is on record, in his book "The Design and Evolution of the
    C++ Programming Language", as regretting the exact details whereby
    "protected" became entrenched in C++, and wishing they could be
    changed... I believe Python's single-underscore is somewhat better), two
    underscores if you ever want to make names hard to override (I used to
    like that, but as time goes by have come to like it less and less; right
    now, unless I have to respect existing coding standards, I entirely
    avoid the double-underscore usage, while single-underscores are OKish).


    Alex
    Alex Martelli, Oct 8, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Simon Brunning
    Replies:
    10
    Views:
    492
    Alex Martelli
    Oct 8, 2005
  2. Tony Meyer
    Replies:
    2
    Views:
    378
    Tony Meyer
    Sep 28, 2005
  3. Simon Brunning
    Replies:
    1
    Views:
    313
    Paul Rubin
    Sep 28, 2005
  4. Chris Gonnerman
    Replies:
    158
    Views:
    2,109
    Paul Rubin
    Oct 5, 2005
  5. Tony Meyer
    Replies:
    0
    Views:
    402
    Tony Meyer
    Sep 29, 2005
Loading...

Share This Page