I recently found the following in a bit of #python sample code:
python
random_data = random.sample(string.hexdigits, 8)
Wait, hexdigits
? I'd use string.ascii_letters
and string.ascii_lowercase
before, but this was the first time I'd seen hexdigits
, which is exactly what you'd think:
The string '0123456789abcdefABCDEF'.
That's useful.