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


Groups > comp.lang.python > #101543

Re: What use of these _ prefix members?

From me <self@example.org>
Newsgroups comp.lang.python
Subject Re: What use of these _ prefix members?
Date 2016-01-12 14:12 +0000
Organization Aioe.org NNTP Server
Message-ID <n731jm$1apr$1@gioia.aioe.org> (permalink)
References <4ee5810e-abe9-4c4b-9ebd-d989b5c2b341@googlegroups.com> <mailman.7.1452450908.3151.python-list@python.org>

Show all headers | View raw


On 2016-01-10, Peter Otten <__peter__@web.de> wrote:
>>>> class Derived(Base):
> ...     def _init(self, x):
> ...         super()._init(x)
> ...         print("do something else with", x)
> ... 
>>>> Derived(42)
> do something with 42
> do something else with 42
><__main__.Derived object at 0x7f8e6b3e9b70>
>

I think you are doing inheritance wrong.

AFAIK you should call directly the __init__() of the parent class, and
pass *args and **kwargs instead.

Except for that, yes, the _init would be conventionally private. Not
enforced by name mangling though.

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


Thread

What use of these _ prefix members? Robert <rxjwg98@gmail.com> - 2016-01-10 09:55 -0800
  Re: What use of these _ prefix members? Steven D'Aprano <steve@pearwood.info> - 2016-01-11 05:03 +1100
  Re: What use of these _ prefix members? Peter Otten <__peter__@web.de> - 2016-01-10 19:34 +0100
    Re: What use of these _ prefix members? me <self@example.org> - 2016-01-12 14:12 +0000
      Re: What use of these _ prefix members? Peter Otten <__peter__@web.de> - 2016-01-12 15:52 +0100
      Re: What use of these _ prefix members? Jason Swails <jason.swails@gmail.com> - 2016-01-12 10:01 -0500

csiph-web