This gives control over the length of the generated string, however, as @Keven mentioned in the comments, if you want less chance of collision in the future, you need to use more characters. Though it seems quite unlikely.
from random import sample
from string import digits, ascii_letters
chars = digits + ascii_letters
#'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
gen_str = sample(chars, 10)
example output:
['2', '8', 'G', 'o', 'U', 'e', 'K', 'f', 'w', '7']
>>> ''.join(gen_str)
'28GoUeKfw7'
info on random module