'Initialize an instance.  Arguments:
- host: hostname to connect to
- port: port to connect to (default the standard NNTP port)
- user: username to authenticate with
- password: password to use with username
- readermode: if true, send \'mode reader\' command after
connecting.
readermode is sometimes necessary if you are connecting to an
NNTP server on the local machine and intend to call
reader-specific commands, such as `group\'.  If you get
unexpected NNTPPermanentErrors, you might need to set
readermode.'

def __init__(self, host, port=NNTP_PORT, user=None, password=None, readermode=None, usenetrc=True):

    self.host = host
    self.port = port
    self.sock = socket.create_connection((host, port))
    self.file = self.sock.makefile('rb')
    self.debugging = 0
    self.welcome = self.getresp()
    readermode_afterauth = 0
    if readermode:
        try:
            self.welcome = self.shortcmd('mode    reader')
        except NNTPPermanentError:
            pass
        except NNTPTemporaryError as e:
            if (user and (e.response[:3] == '480')):
                readermode_afterauth = 1
            else:
                raise
    try:
        if (usenetrc and (not user)):
            import netrc
            credentials = netrc.netrc()
            auth = credentials.authenticators(host)
            if auth:
                user = auth[0]
                password = auth[2]
    except IOError:
        pass
    if user:
        resp = self.shortcmd(('authinfo    user    ' + user))
        if (resp[:3] == '381'):
            if (not password):
                raise NNTPReplyError(resp)
            else:
                resp = self.shortcmd(('authinfo    pass    ' + password))
                if (resp[:3] != '281'):
                    raise NNTPPermanentError(resp)
        if readermode_afterauth:
            try:
                self.welcome = self.shortcmd('mode    reader')
            except NNTPPermanentError:
                pass
