Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:: [': 0.03; 'explicitly': 0.04; 'subject:Python': 0.05; 'method.': 0.05; 'finished.': 0.07; 'override': 0.07; 'rename': 0.07; 'subject:help': 0.07; 'methods,': 0.09; 'pep': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'send()': 0.09; 'shame': 0.09; 'subclass': 0.09; 'subject:2.7': 0.09; 'def': 0.10; 'anyway': 0.11; 'programmer': 0.11; ':-)': 0.13; 'dec': 0.15; "'__doc__',": 0.16; '(when': 0.16; ':-p': 0.16; 'hint': 0.16; 'invokes': 0.16; 'mangled': 0.16; 'no...': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'situation.': 0.16; 'threads': 0.16; 'instance': 0.17; '>>>': 0.18; 'input': 0.18; 'subject:] ': 0.19; 'code.': 0.20; 'written': 0.20; 'software.': 0.21; 'hey': 0.21; 'posted': 0.22; 'programming': 0.23; 'needed.': 0.23; "haven't": 0.23; "i've": 0.23; 'project,': 0.24; 'pass': 0.25; 'skip:[ 10': 0.26; 'scale': 0.27; 'used,': 0.27; 'header:X-Complaints-To:1': 0.28; 'post': 0.28; 'invoke': 0.29; 'methods.': 0.29; 'obj': 0.29; 'parent': 0.29; 'skip:_ 10': 0.29; 'class': 0.29; "i'm": 0.29; "skip:' 10": 0.30; 'worked': 0.30; 'getting': 0.33; 'url:home': 0.33; 'to:addr :python-list': 0.33; "can't": 0.34; 'thanks': 0.34; "won't": 0.35; 'there': 0.35; 'received:org': 0.36; 'but': 0.36; 'wanted': 0.36; 'method': 0.36; 'should': 0.36; 'charset:us-ascii': 0.36; 'subject: (': 0.36; 'possible': 0.37; 'does': 0.37; 'two': 0.37; 'far': 0.37; 'sure': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'think': 0.40; 'your': 0.60; 'days': 0.60; 'first': 0.61; 'skip:n 10': 0.63; 'here': 0.65; 'our': 0.65; 'medical': 0.66; 'subject': 0.66; 'eu,': 0.84; 'nice,': 0.84; 'seldom': 0.84; 'dennis': 0.91; 'grey': 0.95; 'colleagues': 0.97 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: [Newbie] Require help migrating from Perl to Python 2.7 (namespaces) Date: Tue, 25 Dec 2012 16:04:01 -0500 Organization: > Bestiaria Support Staff < References: <3f14f739-e660-4883-a940-c77a6092cb79@googlegroups.com> <928f93e9-8ade-47a1-968d-63af0889b104@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-76-253-108-216.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 3.3/32.846 X-No-Archive: YES X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 63 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1356469450 news.xs4all.nl 6937 [2001:888:2000:d::a6]:60198 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:35497 On Tue, 25 Dec 2012 04:55:06 -0800 (PST), prilisauer@googlemail.com declaimed the following in gmane.comp.python.general: > Hey :-P I think I should rename the threads name into a new "Doc" project, > I'm sure It won't take much time to fill a book with our knowledge. > > Thanks to Rick, you have Posted exactly what I wanted to ask. I know the that > __variable = 'xyz' > _variable = 'xyz' > > are used to make them private, but I haven't found it for methods. Thanks :) > No... Single _ is a hint to the programmer using the name that it is /considered/ "internal" and subject to change -- use at your own risk. Double __ invokes name-mangling so that one does not conflict with a parent class method (when one does NOT want to override the parent class' method with the subclass method). It's a weird, seldom used, situation. >>> class ABC(object): ... def __something(self): ... pass ... def notsomething(self): ... pass ... >>> class XYZ(ABC): ... def __something(self): ... pass ... def notsomething(self): ... pass ... >>> obj = XYZ() >>> dir(obj) ['_ABC__something', '_XYZ__something', '__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'notsomething'] >>> An instance of XYZ has two name-mangled __something methods, but only one not mangled notsomething method. Inside methods of XYZ, any use of __something will invoke _XYZ__something -- but it is possible to explicitly invoke the parent _ABC__something if needed. > I also don't think you're off topic! It's a big grey scale :-) and for me the first post till the last one is a part of my "question" > > PEP, is nice, it tooks me a few days to get trough all your input and my code. Anyway is there also a best practice for naming? eg.: module_class_sub() or wording? eg.: socket: send() recv() -> recv is kept short. according PEP8?? > > > It seems, my english slowly getting better again, If my colleagues would see what I'm writting here they won't belive me. I've worked at the Pharmaceutical IT and made Codereviews and programming for medical software. I still can't belive what I've forgotton the last two years. But still PEP etc. isn't far that hard written like pharm eu, usp, and 21CFR. Shame on me, but I will come back, after I've finished. > > BR -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/