Re: [Tutor] Best way to do FTP login?

2016-06-17 Thread cs
On 17Jun2016 19:07, Michael Selik wrote: On Fri, Jun 17, 2016 at 12:46 PM boB Stepp wrote: ftp = FTP('ip_address', 'username', 'password') Or ftp = FTP('ip_address') ftp.login('username', 'password') Most of the examples I am seeing online use the second approach. Is there some reason why

Re: [Tutor] help with comparing list of tuples in python 2

2016-06-17 Thread Alan Gauld via Tutor
On 17/06/16 20:18, Lulu J wrote: > I have a list of dictionaries. Each dictionary has a word and its position > in the text the positions are in the form of a tuple. > Here is an example: > [ > {'position': (5, 4), 'term': u'happy',}, > {'position': (5, 5), 'term': u'something'} > ] > > for the

Re: [Tutor] Best way to do FTP login?

2016-06-17 Thread Michael Selik
On Fri, Jun 17, 2016 at 12:46 PM boB Stepp wrote: > ftp = FTP('ip_address', 'username', 'password') > > Or > > ftp = FTP('ip_address') > ftp.login('username', 'password') > > Most of the examples I am seeing online use the second approach. Is > there some reason why this is to be preferred? No

[Tutor] help with comparing list of tuples in python 2

2016-06-17 Thread Lulu J
Hi there, My apologies if this is a trivial question but I am sort of new to python. Here is my problem: I have a list of dictionaries. Each dictionary has a word and its position in the text the positions are in the form of a tuple. Here is an example: [ {'position': (5, 4), 'term': u'happy',},

[Tutor] Best way to do FTP login?

2016-06-17 Thread boB Stepp
I could do this: from ftplib import FTP ftp = FTP('ip_address', 'username', 'password') Or, I could do this: ftp = FTP('ip_address') ftp.login('username', 'password') Most of the examples I am seeing online use the second approach. Is there some reason why this is to be preferred? TIA! --

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