[Tutor] ftplib with classes

Gus Tabares gus.tabares@verizon.net
Tue, 27 Aug 2002 09:03:45 -0400


Hello all,

    I'm trying to get my hands dirty with using classes so I decided to 
create a simple program to connect to a ftp and just logout. I know how 
to do this using the interpreter and functions but classes are a 
different story. Looking at the doc for ftplib I see:

  __init__(self, host='', user='', passwd='', acct='')
        # Initialization method (called by class instantiation).
        # Initialize host to localhost, port to standard ftp port
        # Optional arguments are host (for connect()),
        # and user, passwd, acct (for login())

Now the code I have as of now is:

import ftplib

class Connection:
    def __init__(self, host='', user='', passwd='', acct=''):
        self.user = username
        self.host = hostname
        self.passwd = password

Am I doing this right? Also, for connecting ( connect())  would I use 
that as a method? Just looking for a bump in the right direction. Any 
help is appreciated. Thanks...


Gus