Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. import random
  2.  
  3. while True:
  4. generated_barcode = '%012d' % random.randrange(1, 10**12)
  5. # check if this barcode already exists (veeeery very low probability although)
  6. barcode_from_db = sql.find_user_code(generated_barcode)
  7. if barcode_from_db:
  8. log.warning('O_o!!!! GENERATED BARCODE ALREADY EXISTS!!!! Have to generate another one...')
  9. log.warning(' look at this: ' + str(barcode_from_db))
  10. else:
  11. break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement