title: Check whether a Kafka topic exists in Python
body: <p>I want to create a <a href="http://kafka.apache.org/" rel="noreferrer">Kafka</a> topic if it does not already exist. I know how to create a topic via the bash, but I don't know how to check whether it exists.</p>
  
  <pre><code>topic_exists = ??????
  if not topic_exists:
      subprocess.call([os.path.join(KAFKABIN, 'kafka-topics.sh'),
          '--create',  
          '--zookeeper', '{}:2181'.format(KAFKAHOST),
          '--topic', str(self.topic), 
          '--partitions', str(self.partitions),
          '--replication-factor', str(self.replication_factor)])
  </code></pre>