On 17Jun2016 19:07, Michael Selik <michael.se...@gmail.com> wrote:
On Fri, Jun 17, 2016 at 12:46 PM boB Stepp <robertvst...@gmail.com> 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?

Not that I can see. Perhaps only to show that the login method exists.
I suggest using it in a context manager.

   py> with FTP('ftp.example.com', 'username', 'password') as ftp:
   ...     ftp.dir()

I would also recommend looking at the netrc module. This parses the well known file .netrc for login and password, avoiding putting it in your code. You can put clauses for multiple machine in the .netrc, which lets your code work against multiple machines without changes.

Note that the .netrc file still keeps the login and password in the clear, but if you lock the permissions down on your .netrc so that only you can read it there is a degree of security.

Cheers,
Cameron Simpson <c...@zip.com.au>
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to