Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- used = set()
- for i in range(0, 10):
- # Get a random row from my database
- bank_account = random_table_row(datatablebootstrap.BankAccount)
- # Generate a random check number from 10 to 50
- check_number = str(random.randrange(10, 50))
- # Until the combination of bank_account.id and check_number is unique, keep getting another check_number
- while ((bank_account.id, check_number) in used):
- check_number = str(random.randrange(10, 50))
- # populate the database with the new check data
- new_check(bank_account.id, check_number)
- # add the 2-tuple to the set of used 2-tuples so it will not be used again
- used.add((bank_account.id, check_number))
Add Comment
Please, Sign In to add comment