Re: [Python-Dev] Deprecate __ private (was Re: PEP 8 updates/clarifications)

2005-12-14 Thread François Pinard
[Phillip J. Eby] >At 09:53 AM 12/13/2005 -0500, François Pinard wrote: >>Everybody here agrees that this style makes the code much less legible. >I hope you mean, "here at your company or organization", as I disagree. :) Yes, of course! Sorry for the ambiguity. -- François Pinard http://pin

Re: [Python-Dev] Deprecate __ private (was Re: PEP 8 updates/clarifications)

2005-12-14 Thread François Pinard
[Steven Bethard] >import ellogon.utils as utils >import ellogon.features.relations as features_relations >import ellogon.chunking as chunking >import ml.classifiers as _ml_classifiers >import ml.data as _ml_data >The only two-letter one was ElementTree, and the vast majority were >unabbreviated,

Re: [Python-Dev] Deprecate __ private (was Re: PEP 8 updates/clarifications)

2005-12-13 Thread Phillip J. Eby
At 09:53 AM 12/13/2005 -0500, François Pinard wrote: >Everybody here agrees that this style makes the code much less legible. I hope you mean, "here at your company or organization", as I disagree. :) The current draft API guidelines for Chandler encourage the use of short API module names such

Re: [Python-Dev] Deprecate __ private (was Re: PEP 8 updates/clarifications)

2005-12-13 Thread Steven Bethard
On 12/13/05, François Pinard <[EMAIL PROTECTED]> wrote: > [Steven Bethard] > > >Ahh. I never run into this because I never import objects directly > >from modules. So, instead of: > > >from elementtree.ElementTree import ElementTree > >... > >ElementTree(...) > > >I almost always writ

Re: [Python-Dev] Deprecate __ private (was Re: PEP 8 updates/clarifications)

2005-12-13 Thread François Pinard
[Steven Bethard] >Ahh. I never run into this because I never import objects directly >from modules. So, instead of: >from elementtree.ElementTree import ElementTree >... >ElementTree(...) >I almost always write something like: >import elementtree.ElementTree as et >... >

Re: [Python-Dev] Deprecate __ private (was Re: PEP 8 updates/clarifications)

2005-12-13 Thread Adam Olsen
On 12/12/05, Guido van Rossum <[EMAIL PROTECTED]> wrote: > Unfortunately that fails one of the other requirements, which (at the > time of implementation) was minimal impact on the rest of the > interpreter. Since __private isn't limited to self, and attribute > lookup doesn't always result in a di

Re: [Python-Dev] Deprecate __ private (was Re: PEP 8 updates/clarifications)

2005-12-13 Thread Jim Fulton
Guido van Rossum wrote: > On 12/12/05, Jim Fulton <[EMAIL PROTECTED]> wrote: > >>In practice, I don't agree that it works fine. Inevitably, someone >>finds a need to access a "private" variable in a subclass. Or >>even in the original class, you find some need to use something like >>__getattr__

Re: [Python-Dev] Deprecate __ private (was Re: PEP 8 updates/clarifications)

2005-12-12 Thread Guido van Rossum
On 12/12/05, Adam Olsen <[EMAIL PROTECTED]> wrote: > On 12/12/05, Guido van Rossum <[EMAIL PROTECTED]> wrote: > > but that's not the same at all. The point of __private is that it uses > > the *static* scope of the code that contains the reference, not the > > (dynamic) type of the object being ref

Re: [Python-Dev] Deprecate __ private (was Re: PEP 8 updates/clarifications)

2005-12-12 Thread Adam Olsen
On 12/12/05, Guido van Rossum <[EMAIL PROTECTED]> wrote: > but that's not the same at all. The point of __private is that it uses > the *static* scope of the code that contains the reference, not the > (dynamic) type of the object being referenced. With your approach, if > class A defined __private

Re: [Python-Dev] Deprecate __ private (was Re: PEP 8 updates/clarifications)

2005-12-12 Thread Greg Ewing
Neal Norwitz wrote: > I recently asked Guido about name mangling wrt Py3k. He definitely > wanted to keep it in. Unless he changed his mind, I doubt he would > deprecate it. His rationale was that there needs to be a way to > handle name collision with multiple inheritance. Then maybe it shoul

Re: [Python-Dev] Deprecate __ private (was Re: PEP 8 updates/clarifications)

2005-12-12 Thread Steven Bethard
On 12/12/05, Guido van Rossum <[EMAIL PROTECTED]> wrote: > On 12/11/05, Steven Bethard <[EMAIL PROTECTED]> wrote: > > class Document(_cdm.Document): > > ... > > # add convenience methods here > > ... > > Personally, I find that naming convention a mistake. Call it > MyDocument or Enhanc

Re: [Python-Dev] Deprecate __ private (was Re: PEP 8 updates/clarifications)

2005-12-12 Thread Guido van Rossum
On 12/12/05, Scott David Daniels <[EMAIL PROTECTED]> wrote: > Perhaps "The __ name convention is designed for 'mixins'; as a means of > enforcing "private" it is both ineffective and annoying. For example, > distutils.msvccompiler uses a bunch of instance variables which would I > would like to ac

Re: [Python-Dev] Deprecate __ private (was Re: PEP 8 updates/clarifications)

2005-12-12 Thread Guido van Rossum
On 12/12/05, Jim Fulton <[EMAIL PROTECTED]> wrote: > In practice, I don't agree that it works fine. Inevitably, someone > finds a need to access a "private" variable in a subclass. Or > even in the original class, you find some need to use something like > __getattr__ where the implicit name mang

Re: [Python-Dev] Deprecate __ private (was Re: PEP 8 updates/clarifications)

2005-12-12 Thread Guido van Rossum
On 12/12/05, Adam Olsen <[EMAIL PROTECTED]> wrote: > When I need an identifier unique to a class I just use a reference to > the class itself. As such I'd like to suggest that > obj.__private > be converted to > obj.__dict__[(type(obj), '__private')] > > Note that I'm accessing __dict__ directly s

Re: [Python-Dev] Deprecate __ private (was Re: PEP 8 updates/clarifications)

2005-12-12 Thread Guido van Rossum
On 12/11/05, Steven Bethard <[EMAIL PROTECTED]> wrote: > On 12/11/05, Guido van Rossum <[EMAIL PROTECTED]> wrote: > > I know about the fear of accidental reuse of class names, but I don't > > find it a compelling argument. > > FWIW, I know I currently have a number of classes that are potentially >

Re: [Python-Dev] Deprecate __ private (was Re: PEP 8 updates/clarifications)

2005-12-12 Thread Scott David Daniels
Jeremy Hylton wrote: > On 12/12/05, Scott David Daniels <[EMAIL PROTECTED]> wrote: >> Perhaps "The __ name convention is designed for 'mixins'; as a means of >> enforcing "private" it is both ineffective and annoying. For example, >> distutils.msvccompiler uses a bunch of instance variables which

Re: [Python-Dev] Deprecate __ private (was Re: PEP 8 updates/clarifications)

2005-12-12 Thread Jeremy Hylton
On 12/12/05, Scott David Daniels <[EMAIL PROTECTED]> wrote: > Jim Fulton wrote: > > Ian Bicking wrote: > >> Jim Fulton wrote: > >>> Ian Bicking wrote: > Private attributes should have two leading underscores, no > trailing underscores. > > This conflicts with a pre

Re: [Python-Dev] Deprecate __ private (was Re: PEP 8 updates/clarifications)

2005-12-12 Thread Scott David Daniels
Jim Fulton wrote: > Ian Bicking wrote: >> Jim Fulton wrote: >>> Ian Bicking wrote: Private attributes should have two leading underscores, no trailing underscores. This conflicts with a previous suggestion "Generally, double leading underscores should be used

Re: [Python-Dev] Deprecate __ private (was Re: PEP 8 updates/clarifications)

2005-12-12 Thread Adam Olsen
[Quotations deleted since I'm not replying to anything directly] When I need an identifier unique to a class I just use a reference to the class itself. As such I'd like to suggest that obj.__private be converted to obj.__dict__[(type(obj), '__private')] Note that I'm accessing __dict__ directly

Re: [Python-Dev] Deprecate __ private (was Re: PEP 8 updates/clarifications)

2005-12-12 Thread Jim Fulton
Tim Peters wrote: > [Neal Norwitz] > ... > That was the only point to `__` name-mangling. People who think it's > trying to, e.g., emulate C++'s `private` gimmick are enjoying a > semi-private fantasy ;-) It works fine for its intended use. In theory, I agree. In practice, I don't agree that

Re: [Python-Dev] Deprecate __ private (was Re: PEP 8 updates/clarifications)

2005-12-12 Thread Steve Holden
Tim Peters wrote: > [Neal Norwitz] > >>I recently asked Guido about name mangling wrt Py3k. He definitely >>wanted to keep it in. Unless he changed his mind, I doubt he would >>deprecate it. His rationale was that there needs to be a way to >>handle name collision with multiple inheritance. >

Re: [Python-Dev] Deprecate __ private (was Re: PEP 8 updates/clarifications)

2005-12-11 Thread Steven Bethard
On 12/11/05, Guido van Rossum <[EMAIL PROTECTED]> wrote: > On 12/11/05, Nick Coghlan <[EMAIL PROTECTED]> wrote: > > Keeping it for Py3K would be fine, if the mechanism was changed so that it > > actually worked right. That is, the mechanics would be such that any two > > concurrently existing class

Re: [Python-Dev] Deprecate __ private (was Re: PEP 8 updates/clarifications)

2005-12-11 Thread João Paulo Silva
Hi All, I think that a big problem is that there isn't an obvious way to say: self.a is part of the class interface, self.b isn't. Or: you can override self._c to do that. I believe we really need a way to do these things more clear. Currently we can use methods and properties, but even this is no

Re: [Python-Dev] Deprecate __ private (was Re: PEP 8 updates/clarifications)

2005-12-11 Thread Guido van Rossum
On 12/11/05, Nick Coghlan <[EMAIL PROTECTED]> wrote: > Keeping it for Py3K would be fine, if the mechanism was changed so that it > actually worked right. That is, the mechanics would be such that any two > concurrently existing classes would be guaranteed to mangle the names of their > private var

Re: [Python-Dev] Deprecate __ private (was Re: PEP 8 updates/clarifications)

2005-12-11 Thread Clark C. Evans
Interesting discussion. I've been thinking the opposite; that I should start using __attribute more often for "undocumented, private" member variables that are implementation details and clearly not part of the public interface. I'm curious what people have against it? On Sun, Dec 11, 2005 at 09

Re: [Python-Dev] Deprecate __ private (was Re: PEP 8 updates/clarifications)

2005-12-11 Thread Nick Coghlan
Neal Norwitz wrote: > On 12/11/05, Jim Fulton <[EMAIL PROTECTED]> wrote: >> Can we officially mark __private as a mistake. Perhaps: >> >> - Strongly discourage it in the style guide > > This may be acceptable. > >> - Mark it in the language reference as a deprecated feature >> >> - Generate depre

Re: [Python-Dev] Deprecate __ private (was Re: PEP 8 updates/clarifications)

2005-12-11 Thread Tim Peters
[Neal Norwitz] > I recently asked Guido about name mangling wrt Py3k. He definitely > wanted to keep it in. Unless he changed his mind, I doubt he would > deprecate it. His rationale was that there needs to be a way to > handle name collision with multiple inheritance. That wasn't quite it. Th

Re: [Python-Dev] Deprecate __ private (was Re: PEP 8 updates/clarifications)

2005-12-11 Thread Neal Norwitz
On 12/11/05, Jim Fulton <[EMAIL PROTECTED]> wrote: > > Can we officially mark __private as a mistake. Perhaps: > > - Strongly discourage it in the style guide This may be acceptable. > - Mark it in the language reference as a deprecated feature > > - Generate deprecation warnings when it is used?

Re: [Python-Dev] Deprecate __ private (was Re: PEP 8 updates/clarifications)

2005-12-11 Thread Steven Bethard
Jim Fulton wrote: > Can we officially mark __private as a mistake. Perhaps: > > - Strongly discourage it in the style guide +1 > - Mark it in the language reference as a deprecated feature +1 > - Generate deprecation warnings when it is used? -0 I don't see that this gains us much. It will c

[Python-Dev] Deprecate __ private (was Re: PEP 8 updates/clarifications)

2005-12-11 Thread Jim Fulton
Ian Bicking wrote: > Jim Fulton wrote: > ... >>>Also decide whether your attributes should be private or not. >>>The difference between private and non-public is that the former >>>will never be useful for a derived class, while the latter might >>>be. Yes, you sho