[Tutor] Py 2.4.4: Inheriting from ftplib.FTP()

Michael Selik michael.selik at gmail.com
Fri Jun 17 11:57:25 EDT 2016


On Fri, Jun 17, 2016 at 11:42 AM boB Stepp <robertvstepp at gmail.com> wrote:

> On Thu, Jun 16, 2016 at 11:40 AM, Alan Gauld via Tutor <tutor at python.org>
> wrote:
> > On 16/06/16 16:38, boB Stepp wrote:
> >
> >> class FTPFiles(FTP, object):
> >>     """FTP files to Windows server location(s)."""
>
> I was struggling to come up with a good name here that would not cause
> me any name collision issues with the contents of ftplib.FTP().


That's why we have namespaces. Your ``FTP`` would not collide with
``ftplib.FTP``, because they are in separate modules.

I looked up LSP last night.  I can see how I can easily get burned
>
even on something seemingly simple.  One example, which I imagine is
> often used, is of a square class inheriting from a rectangle class.
> Squares have same sized sides; rectangles not necessarily so.  So any
> size changing methods from the rectangle class inherited by the square
> class can potentially wreak havoc on squares.  Am I getting the
> essence of the potential issues I might encounter?
>

Yes, that's the gist of it. It's very hard to anticipate what features your
base class may need in the future, months or years down the road. Many of
them may be inappropriate for one or more child classes.


More information about the Tutor mailing list