title: Creating a reusable class in python
body: <p>I need to work with remote files transparently as if they were local files in some python code I'm writing, so I decided to use SFTP for this task.  The following code example works (it prints the first line of the remote file):</p>
  
  <pre><code>import paramiko
  
  client = paramiko.SSHClient()
  client.load_system_host_keys()
  client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  client.connect(hostname='192.168.8.103', username='root', password='pyjamas')
  sftp = client.open_sftp()
  test = sftp.open('/var/log/example/ingest.log', mode='r', bufsize=1)
  print test.readline()
  </code></pre>
  
  <p>I am going to be connecting to many files, so I decided to write a class that gives me an SFTPFile object.  Examine the following code:</p>
  
  <pre><code>import paramiko
  
  class RemoteLog(object):
      """This class implements the remote log buffer."""
  
      def __init__(self, host, user='', pw='', log=''):
          """Initializes a connection to a remote log."""
  
          client = paramiko.SSHClient()
          client.load_system_host_keys()
          client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
          client.connect(hostname=host, username=user, password=pw)
          sftp = client.open_sftp()
          self.log = sftp.open(log, mode='r', bufsize=1)
  
  if __name__ == "__main__":
      test = RemoteLog(host='192.168.8.103', user='root', pw='pyjamas', log='/var/log/example/ingest.log')
      print test.log.readline()
  </code></pre>
  
  <p>Unfortunately readline() in this scenario returns nothing.  There are no errors or obvious explanations.</p>
  
  <p>How should I replicate the functionality from my first code snippet into a reusable class?</p>