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


Groups > comp.lang.python > #104920

Re: Encapsulation in Python

Newsgroups comp.lang.python
Date 2016-03-14 23:09 -0700
References (1 earlier) <mailman.139.1457623672.15725.python-list@python.org> <6984dafc-fffd-4d46-a173-421bb5c142d2@googlegroups.com> <mailman.25.1457711277.26429.python-list@python.org> <4ddc3696-3f71-4598-98a6-929267f51fb9@googlegroups.com> <0f3936b8-9a77-4981-bfd0-802d3392e567@googlegroups.com>
Message-ID <bbafce4c-85b9-4d3f-9d3d-2e8e90318366@googlegroups.com> (permalink)
Subject Re: Encapsulation in Python
From Rick Johnson <rantingrickjohnson@gmail.com>

Show all headers | View raw


On Monday, March 14, 2016 at 1:12:14 PM UTC-5, sohca...@gmail.com wrote:

[...a whole lot of my quotes, snipped for bandwidth...]

@GROUP: I don't know what the heck happened in this thread,
but everyone involved was having a nice respectful
conversation about encapsulation, interfaces, and modules,
and then BartC and Mark showed up, and the thread went off
on a wild tangent. Whilst the participation of members and
the CoC are important topics, i hope we put aside these
petty issues, and get back to productive discussions soon.
Thanks.

> I don't think you'll find anyone that disagrees with you
> here.
> 
> If you're seeing a method "width", then whoever wrote that
> method is a terrible programmer.  Method names should
> *always* contain some sort of verb.  As you just said,
> self-documenting names are the key to short learning
> curves.
> 
> IMO, if you intend an attribute to be read-only, then you
> should use a getter, even in Python, 

Even though many of our fellow members would argue that this
is overkill, your advice is good advice, and i strongly
support this position.

> and of course prefix the actual value with an underscore
> to show it should not be accessed publicly.

Agreed!

> The only time you should see "someObject.width" is if
> width is both readable and writable.  Of course, Using
> @property to add some logic to the setting/getting is
> fine.

Yes. More wonderful, and consistent, advice here. You sir,
have restored my faith in humanity.

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


Thread

Re: Encapsulation in Python Ian Kelly <ian.g.kelly@gmail.com> - 2016-03-10 08:27 -0700
  Re: Encapsulation in Python Rick Johnson <rantingrickjohnson@gmail.com> - 2016-03-10 16:45 -0800
    Re: Encapsulation in Python Ian Kelly <ian.g.kelly@gmail.com> - 2016-03-11 08:47 -0700
      Re: Encapsulation in Python Rick Johnson <rantingrickjohnson@gmail.com> - 2016-03-11 18:39 -0800
        Re: Encapsulation in Python Ian Kelly <ian.g.kelly@gmail.com> - 2016-03-12 09:44 -0700
          Re: Encapsulation in Python Rick Johnson <rantingrickjohnson@gmail.com> - 2016-03-12 19:11 -0800
          Re: Encapsulation in Python Steven D'Aprano <steve@pearwood.info> - 2016-03-13 21:11 +1100
            Re: Encapsulation in Python Rick Johnson <rantingrickjohnson@gmail.com> - 2016-03-14 10:32 -0700
              Re: Encapsulation in Python Ian Kelly <ian.g.kelly@gmail.com> - 2016-03-14 15:09 -0600
              Re: Encapsulation in Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-14 21:23 +0000
                Re: Encapsulation in Python BartC <bc@freeuk.com> - 2016-03-14 22:07 +0000
                Re: Encapsulation in Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-14 22:20 +0000
                Re: Encapsulation in Python BartC <bc@freeuk.com> - 2016-03-14 22:40 +0000
                Re: Encapsulation in Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-14 23:19 +0000
                Re: Encapsulation in Python BartC <bc@freeuk.com> - 2016-03-14 23:56 +0000
                Re: Encapsulation in Python Chris Angelico <rosuav@gmail.com> - 2016-03-15 11:12 +1100
                Re: Encapsulation in Python BartC <bc@freeuk.com> - 2016-03-15 00:54 +0000
                Re: Encapsulation in Python Chris Angelico <rosuav@gmail.com> - 2016-03-15 11:58 +1100
                Re: Encapsulation in Python BartC <bc@freeuk.com> - 2016-03-15 01:22 +0000
                Re: Encapsulation in Python Chris Angelico <rosuav@gmail.com> - 2016-03-15 13:02 +1100
                Re: Encapsulation in Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-15 00:28 +0000
                Re: Encapsulation in Python BartC <bc@freeuk.com> - 2016-03-15 01:10 +0000
                Re: Encapsulation in Python Chris Angelico <rosuav@gmail.com> - 2016-03-15 12:23 +1100
                Re: Encapsulation in Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-15 04:41 +0000
                Re: Encapsulation in Python rurpy@yahoo.com - 2016-03-14 17:17 -0700
                Re: Encapsulation in Python Chris Angelico <rosuav@gmail.com> - 2016-03-15 11:25 +1100
                Re: Encapsulation in Python Steven D'Aprano <steve@pearwood.info> - 2016-03-15 13:06 +1100
                Re: Encapsulation in Python Chris Angelico <rosuav@gmail.com> - 2016-03-15 13:14 +1100
                Re: Encapsulation in Python Steven D'Aprano <steve@pearwood.info> - 2016-03-15 13:40 +1100
                Re: Encapsulation in Python Rick Johnson <rantingrickjohnson@gmail.com> - 2016-03-14 21:08 -0700
                Re: Encapsulation in Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-15 00:47 +0000
                Re: Encapsulation in Python Steven D'Aprano <steve@pearwood.info> - 2016-03-15 13:46 +1100
                Re: Encapsulation in Python Chris Angelico <rosuav@gmail.com> - 2016-03-15 11:56 +1100
                Re: Encapsulation in Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-15 04:36 +0000
                Re: Encapsulation in Python Steven D'Aprano <steve@pearwood.info> - 2016-03-15 13:01 +1100
                Re: Encapsulation in Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-15 04:45 +0000
                Re: Encapsulation in Python Christian Gollwitzer <auriocus@gmx.de> - 2016-03-15 22:02 +0100
                Re: Encapsulation in Python BartC <bc@freeuk.com> - 2016-03-16 00:39 +0000
                Re: Encapsulation in Python BartC <bc@freeuk.com> - 2016-03-16 22:58 +0000
        Re: Encapsulation in Python sohcahtoa82@gmail.com - 2016-03-14 11:11 -0700
          Re: Encapsulation in Python Rick Johnson <rantingrickjohnson@gmail.com> - 2016-03-14 23:09 -0700
      Re: Encapsulation in Python Rick Johnson <rantingrickjohnson@gmail.com> - 2016-03-11 18:56 -0800
    Re: Encapsulation in Python Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-03-12 13:52 +1300
      Re: Encapsulation in Python Rick Johnson <rantingrickjohnson@gmail.com> - 2016-03-12 08:49 -0800
        Re: Encapsulation in Python Chris Angelico <rosuav@gmail.com> - 2016-03-13 08:10 +1100
          Re: Encapsulation in Python Rick Johnson <rantingrickjohnson@gmail.com> - 2016-03-12 19:36 -0800
            Re: Encapsulation in Python Chris Angelico <rosuav@gmail.com> - 2016-03-13 15:05 +1100
        Re: Encapsulation in Python Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-03-14 12:35 +1300
          Re: Encapsulation in Python Rick Johnson <rantingrickjohnson@gmail.com> - 2016-03-14 15:55 -0700

csiph-web