Overriding a global

Joshua Landau joshua.landau.ws at gmail.com
Tue Dec 13 03:34:59 EST 2011


On 13/12/2011, Ian Kelly <ian.g.kelly at gmail.com> wrote:
> On Mon, Dec 12, 2011 at 4:48 PM, Joshua Landau
> <joshua.landau.ws at gmail.com> wrote:
>> Rebinding logger locally in a function is really no
>> different to a subclass rebinding a variable from its main class using
>> that
>> class' value. The only difference is that, in that case, you have an
>> alternate binding to the original value.
>
> 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.

I'd make this longer, but I've got class now :(



More information about the Python-list mailing list