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


Groups > comp.lang.python > #17168

Re: Overriding a global

References (7 earlier) <CAN1F8qWYRSq0oUTzeDn-+SYXdHr7+akAQPSk-R+90Ax7E1FAZQ@mail.gmail.com> <CALwzidngv952LTEguRcP9Pj3_-tZTNpqvqkjcid5sje63N8hkg@mail.gmail.com> <CAN1F8qX_O1oh-f_VcyA-ZhgfyNWFWFLUATvRQzvmEpfhRNJ_OA@mail.gmail.com> <CALwzid=aBaQk-kDoJe5B+ihJ7dxn4G21Qgm3SMHzq8Jf_5qj5g@mail.gmail.com> <CAN1F8qVBUu_Rp3tzxy_x=phS+G3KjAafOpkS1tsTGcC9EF=LiA@mail.gmail.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2011-12-13 12:54 -0700
Subject Re: Overriding a global
Newsgroups comp.lang.python
Message-ID <mailman.3618.1323806080.27778.python-list@python.org> (permalink)

Show all headers | View raw


On Tue, Dec 13, 2011 at 12:43 PM, Joshua Landau
<joshua.landau.ws@gmail.com> wrote:
> On 13 December 2011 19:34, Ian Kelly <ian.g.kelly@gmail.com> wrote:
>>
>> On Tue, Dec 13, 2011 at 1:34 AM, Joshua Landau
>> <joshua.landau.ws@gmail.com> wrote:
>> >> No, there is another difference, the reason for rebinding the name.
>> >> In a subclass, you would rebind a class attribute because that
>> >> particular attribute, which you need to change, is used and expected
>> >> by external code, either in the base class or in code that uses its
>> >> API (or both).  Local variables in functions, on the other hand, are
>> >> not externally visible, so there is no need to do this in order to
>> >> conform to the expectations of external code.  All it does in that
>> >> case is to sow potential confusion.
>> >>
>> > So you're saying you should never extend methods or attributes that
>> > aren't meant to be used as part of of the API? Because I can claim
>> > guilty on this point.
>>
>> No, I'm only saying that replacing attributes in subclasses is
>> accepted because it is necessary due to external dependencies, and
>> that local variables in functions don't have that excuse.
>
>
> But they aren't needed due to external dependencies if they're
> implementation-specific and not part of the API, no?

By "external dependencies" I mean anything that's not specifically
part of the subclass.  This includes the base class.  If they're not
part of the API, then the base class presumably uses them for
something, and by replacing them, you change the behavior of that base
functionality.  That's an external dependency.

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


Thread

Overriding a global Roy Smith <roy@panix.com> - 2011-12-10 15:47 -0500
  Re: Overriding a global MRAB <python@mrabarnett.plus.com> - 2011-12-10 21:07 +0000
    Re: Overriding a global Roy Smith <roy@panix.com> - 2011-12-10 16:10 -0500
      Re: Overriding a global Jean-Michel Pichavant <jeanmichel@sequans.com> - 2011-12-12 12:13 +0100
        Re: Overriding a global Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-12 21:28 +0000
          Re: Overriding a global Dave Angel <d@davea.name> - 2011-12-12 16:43 -0500
            Re: Overriding a global Ben Finney <ben+python@benfinney.id.au> - 2011-12-13 09:27 +1100
              Re: Overriding a global Dave Angel <d@davea.name> - 2011-12-12 20:46 -0500
              Re: Overriding a global Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-13 01:48 +0000
              Re: Overriding a global Ian Kelly <ian.g.kelly@gmail.com> - 2011-12-12 22:50 -0700
              Re: Overriding a global Joshua Landau <joshua.landau.ws@gmail.com> - 2011-12-13 08:34 +0000
              Re: Overriding a global Ian Kelly <ian.g.kelly@gmail.com> - 2011-12-13 12:34 -0700
              Re: Overriding a global Ian Kelly <ian.g.kelly@gmail.com> - 2011-12-13 12:54 -0700
          Re: Overriding a global Jean-Michel Pichavant <jeanmichel@sequans.com> - 2011-12-13 10:54 +0100
            Re: Overriding a global Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-13 11:15 +0000
              Re: Overriding a global Jean-Michel Pichavant <jeanmichel@sequans.com> - 2011-12-13 14:30 +0100
              Re: Overriding a global Jean-Michel Pichavant <jeanmichel@sequans.com> - 2011-12-14 11:14 +0100
              Re: Overriding a global Chris Angelico <rosuav@gmail.com> - 2011-12-14 21:32 +1100
              Re: Overriding a global Jean-Michel Pichavant <jeanmichel@sequans.com> - 2011-12-14 13:05 +0100
                Re: Overriding a global Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-14 12:53 +0000
                Re: Overriding a global Jean-Michel Pichavant <jeanmichel@sequans.com> - 2011-12-14 14:35 +0100
              Re: Overriding a global Chris Angelico <rosuav@gmail.com> - 2011-12-14 23:21 +1100
              Re: Overriding a global Jean-Michel Pichavant <jeanmichel@sequans.com> - 2011-12-14 18:06 +0100
  Re: Overriding a global Terry Reedy <tjreedy@udel.edu> - 2011-12-10 19:14 -0500
  Re: Overriding a global Terry Reedy <tjreedy@udel.edu> - 2011-12-10 19:19 -0500
  Re: Overriding a global Peter Otten <__peter__@web.de> - 2011-12-11 09:14 +0100
  Re: Overriding a global Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2011-12-13 10:15 +0100

csiph-web