For a while now the binary distribution as included a tool to calculate tokens:

aarons-MBP-2011:apache-cassandra-1.2.11 aaron$ tools/bin/token-generator 
Token Generator Interactive Mode

 How many datacenters will participate in this Cassandra cluster? 1
 How many nodes are in datacenter #1? 3

DC #1:
  Node #1:                                        0
  Node #2:   56713727820156410577229101238628035242
  Node #3:  113427455640312821154458202477256070484


Aaron Morton
New Zealand

Co-Founder & Principal Consultant
Apache Cassandra Consulting

On 2/11/2013, at 3:43 am, Ray Sutton <> wrote:

Your quotes need to be escaped:
python -c "num=2; print \"\n\".join([(\"token %d: %d\" %(i,(i*(2**127)/num))) for i in range(0,num)])"

Ray  //o-o\\

On Fri, Nov 1, 2013 at 10:36 AM, Peter Sanford <> wrote:
I can't tell you why that one-liner isn't working, but you can try for generating balanced tokens.

On Thu, Oct 31, 2013 at 11:59 PM, Techy Teck <> wrote:
I am trying to setup two node Cassandra Cluster on windows machine. I have basically two windows machine and I was following this datastax tutorial (

Whenever I use the below command to get the token number from the above tutorial -

    python -c "num=2; print ""\n"".join([(""token %d: %d"" %(i,(i*(2**127)/num))) for i in range(0,num)])"

I always get this error -

    C:\Users\username>python -c "num=2; print ""\n"".join([(""token %d: %d"" %(i,(i*(2**127)/num))) for i
    in range(0,num)])"
      File "<string>", line 1
        num=2; print "\n".join([("token %d: %d" %(i,(i*(2**127)/num))) for i in range(0,num)])
    SyntaxError: invalid syntax