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

2016-06-17 Thread Michael Selik
On Fri, Jun 17, 2016 at 11:42 AM boB Stepp wrote: > On Thu, Jun 16, 2016 at 11:40 AM, Alan Gauld via Tutor > 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 na

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

2016-06-17 Thread Alan Gauld via Tutor
On 17/06/16 16:41, boB Stepp wrote: >> Inheritance is a powerful tool but it carries lots of potential for >> problems too,... > > 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

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

2016-06-17 Thread boB Stepp
I guess I did not emphasize enough that I was just starting to think through this. The code I posted yesterday was more in the way of exploratory code, trying to understand how to implement inheritance, using new-style classes (I am trying to integrate the work with Python 3 at home as much as pos

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

2016-06-17 Thread boB Stepp
On Thu, Jun 16, 2016 at 11:40 AM, Alan Gauld via Tutor wrote: > On 16/06/16 16:38, boB Stepp wrote: > >> class FTPFiles(FTP, object): >> """FTP files to Windows server location(s).""" > > OK, First comment. You describe this as an action(verb) > rather than a noun. Classes should represent nou

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

2016-06-17 Thread Steven D'Aprano
Some futher thoughts: On Thu, Jun 16, 2016 at 10:38:13AM -0500, boB Stepp wrote: > class FTPFiles(FTP, object): > """FTP files to Windows server location(s).""" > > def __init__(self, host=server_ip, user=user, passwd=passwd): > """Initialize FTPFiles object. Normally the default

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

2016-06-17 Thread Steven D'Aprano
On Thu, Jun 16, 2016 at 10:38:13AM -0500, boB Stepp wrote: > I am extremely gradually trying to dip my big toe into the waters of > writing classes. [...] > What I learned today: > > 1) FTP from ftplib appears to be an old-style class. > > 2) I can't just use "class FTPFiles(FTP)" or I will b

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

2016-06-16 Thread Alan Gauld via Tutor
On 16/06/16 16:38, boB Stepp wrote: > class FTPFiles(FTP, object): > """FTP files to Windows server location(s).""" OK, First comment. You describe this as an action(verb) rather than a noun. Classes should represent nouns (objects) not actions. FTP represents a protocol connection with which

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

2016-06-16 Thread boB Stepp
I am extremely gradually trying to dip my big toe into the waters of writing classes. I have a little bit of extra time at work today, so I thought I would start writing a class to replace a bunch of shell FTP scripts I've used in various programs that would be flexible enough to be reused whereve