Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #31025

Re: Private methods

From Robert Kern <robert.kern@gmail.com>
Subject Re: Private methods
Date 2012-10-09 15:12 +0100
References <1krpbz9.1wge3j11123k2vN%real-not-anti-spam-address@apple-juice.co.uk> <mailman.1994.1349790529.27098.python-list@python.org> <1krpdak.u0qy9e1a4knspN%real-not-anti-spam-address@apple-juice.co.uk>
Newsgroups comp.lang.python
Message-ID <mailman.1996.1349791978.27098.python-list@python.org> (permalink)

Show all headers | View raw


On 10/9/12 2:59 PM, D.M. Procida wrote:
> Mark Lawrence <breamoreboy@yahoo.co.uk> wrote:
>
>> On 09/10/2012 14:24, D.M. Procida wrote:
>>> What exactly is the point of a private method? Why or when would I want
>>> to use one?
>>>
>>> Daniele
>>>
>>
>> Hardly a Python question but using a search engine could have got you
>> here, and rather faster :)
>>
> http://stackoverflow.com/questions/2620699/why-private-methods-in-the-ob
> ject-oriented
>
> Thanks. Sometimes I prefer to talk to real people on Usenet than do web
> searches. Just my preference.

That's understandable, but the real people on Usenet who will answer your 
questions usually prefer that you do a web search first, for a variety of reasons.

   http://www.catb.org/esr/faqs/smart-questions.html#before

> Anyway, one of the answers on that page explains that public methods are
> interfaces to a class, that other things might rely on, and private ones
> are for its own internal logic, that other things don't need to care
> about.
>
> In Python, using an underscore is simply a convention to note that a
> method is private - it doesn't actually hide it from other things -
> correct?

This is correct.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Private methods real-not-anti-spam-address@apple-juice.co.uk (D.M. Procida) - 2012-10-09 14:24 +0100
  Re: Private methods Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-10-09 14:51 +0100
    Re: Private methods real-not-anti-spam-address@apple-juice.co.uk (D.M. Procida) - 2012-10-09 14:59 +0100
      Re: Private methods Demian Brecht <demianbrecht@gmail.com> - 2012-10-09 07:08 -0700
      Re: Private methods Robert Kern <robert.kern@gmail.com> - 2012-10-09 15:12 +0100
      Re: Private methods Tim Chase <python.list@tim.thechases.com> - 2012-10-09 09:21 -0500
      Re: Private methods Ian Kelly <ian.g.kelly@gmail.com> - 2012-10-09 11:08 -0600
        Re: Private methods Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-10-09 23:51 +0000
          Re: Private methods Demian Brecht <demianbrecht@gmail.com> - 2012-10-09 17:26 -0700
            Re: Private methods real-not-anti-spam-address@apple-juice.co.uk (D.M. Procida) - 2012-10-10 08:03 +0100
              Re: Private methods alex23 <wuwei23@gmail.com> - 2012-10-10 18:34 -0700
                Re: Private methods Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-10-11 02:08 +0000
                Re: Private methods Dieter Maurer <dieter@handshake.de> - 2012-10-11 08:04 +0200
          Re: Private methods Robert Kern <robert.kern@gmail.com> - 2012-10-10 13:47 +0100
          Re: Private methods Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-01 16:45 -0600
      Re: Private methods Roy Smith <roy@panix.com> - 2012-10-10 09:08 -0400
        Re: Private methods Ramchandra Apte <maniandram01@gmail.com> - 2012-10-10 08:56 -0700
          Re: Private methods Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-10-10 17:13 +0100
            Re: Private methods Grant Edwards <invalid@invalid.invalid> - 2012-10-10 16:30 +0000
            Re: Private methods alex23 <wuwei23@gmail.com> - 2012-10-10 18:39 -0700
  Re: Private methods 88888 Dihedral <dihedral88888@googlemail.com> - 2012-10-10 20:11 -0700

csiph-web