Python Forum

Full Version: Sequence Generator - Long number
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

Any way i can redo same Java code to Python.

Usecase: Sequence Generator - if i give as LongSequence('s1',1100110000000001,1) - should return 1100110000000002

	private static final java.util.Map<String, Long> seq_Hash = new java.util.HashMap<String, Long>();
    public static Long LongSequence(String seqName, Long startValue, int step) {
      if (seq_Hash.containsKey(seqName)) {
          seq_Hash.put(seqName, seq_Hash.get(seqName) + step);
                if(seq_Hash.get(seqName)>9999999999999999L){
                      seq_Hash.put(seqName, 0L);
                }
          return seq_Hash.get(seqName);
      } else {
          seq_Hash.put(seqName, startValue);
          return startValue;
      }
  }
Thanks
This forum is focused more on education than writing others' code for them. If you give it a try yourself, we'd be happy to help with any issues you run into.
Also, why do you want to translate this?
In addition, if you explain in plain english what your goal is you will have a better chance on getting help. Not everyone is familiar with JAVA...