title: Improper use of __new__ to generate class instances?
body: <p>I'm creating some classes for dealing with filenames in various types of file shares (nfs, afp, s3, local disk) etc.  I get as user input a string that identifies the data source (i.e. <code>"nfs://192.168.1.3"</code> or <code>"s3://mybucket/data"</code>) etc.  </p>
  
  <p>I'm subclassing the specific filesystems from a base class that has common code.  Where I'm confused is in the object creation. What I have is the following:</p>
  
  <pre><code>import os
  
  class FileSystem(object):
      class NoAccess(Exception):
          pass
  
      def __new__(cls,path):
          if cls is FileSystem:
              if path.upper().startswith('NFS://'): 
                  return super(FileSystem,cls).__new__(Nfs)
              else: 
                  return super(FileSystem,cls).__new__(LocalDrive)
          else:
              return super(FileSystem,cls).__new__(cls,path)
  
      def count_files(self):
          raise NotImplementedError
  
  class Nfs(FileSystem):
      def __init__ (self,path):
          pass
  
      def count_files(self):
          pass
  
  class LocalDrive(FileSystem):
      def __init__(self,path):
          if not os.access(path, os.R_OK):
              raise FileSystem.NoAccess('Cannot read directory')
          self.path = path
  
      def count_files(self):
          return len([x for x in os.listdir(self.path) if os.path.isfile(os.path.join(self.path, x))])
  
  data1 = FileSystem('nfs://192.168.1.18')
  data2 = FileSystem('/var/log')
  
  print type(data1)
  print type(data2)
  
  print data2.count_files()
  </code></pre>
  
  <p>I thought this would be a good use of <code>__new__</code> but most posts I read about it's use discourage it. Is there a more accepted way to approach this problem?</p>