title: How to get latest offset for a partition for a kafka topic?
body: <p>I am using the Python high level consumer for Kafka and want to know the latest offsets for each partition of a topic. However I cannot get it to work. </p>
  
  <pre><code>from kafka import TopicPartition
  from kafka.consumer import KafkaConsumer
  
  con = KafkaConsumer(bootstrap_servers = brokers)
  ps = [TopicPartition(topic, p) for p in con.partitions_for_topic(topic)]
  
  con.assign(ps)
  for p in ps:
      print "For partition %s highwater is %s"%(p.partition,con.highwater(p))
  
  print "Subscription = %s"%con.subscription()
  print "con.seek_to_beginning() = %s"%con.seek_to_beginning()
  </code></pre>
  
  <p>But the output I get is </p>
  
  <pre><code>For partition 0 highwater is None
  For partition 1 highwater is None
  For partition 2 highwater is None
  For partition 3 highwater is None
  For partition 4 highwater is None
  For partition 5 highwater is None
  ....
  For partition 96 highwater is None
  For partition 97 highwater is None
  For partition 98 highwater is None
  For partition 99 highwater is None
  Subscription = None
  con.seek_to_beginning() = None
  con.seek_to_end() = None
  </code></pre>
  
  <p>I have an alternate approach using <code>assign</code> but the result is the same</p>
  
  <pre><code>con = KafkaConsumer(bootstrap_servers = brokers)
  ps = [TopicPartition(topic, p) for p in con.partitions_for_topic(topic)]
  
  con.assign(ps)
  for p in ps:
      print "For partition %s highwater is %s"%(p.partition,con.highwater(p))
  
  print "Subscription = %s"%con.subscription()
  print "con.seek_to_beginning() = %s"%con.seek_to_beginning()
  print "con.seek_to_end() = %s"%con.seek_to_end()
  </code></pre>
  
  <p>It seems from some of the documentation that I might get this behaviour if a <code>fetch</code> has not been issued. But I cannot find a way to force that. What am I doing wrong?</p>
  
  <p>Or is there a different/simpler way to get the latest offsets for a topic?</p>