On 13 December 2011 19:54, Ian Kelly <ian.g.ke...@gmail.com> wrote: > On Tue, Dec 13, 2011 at 12:43 PM, Joshua Landau > <joshua.landau...@gmail.com> wrote: > > On 13 December 2011 19:34, Ian Kelly <ian.g.ke...@gmail.com> wrote: > >> > >> On Tue, Dec 13, 2011 at 1:34 AM, Joshua Landau > >> <joshua.landau...@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. >
Touché. On this point, I yield.
-- http://mail.python.org/mailman/listinfo/python-list