The Monkinetic Weblog

circa 2024

powered-by

string.hexdigits #

Posted 2020-02-13 03:09

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.

 
 

monkinetic.blog is powered by python, Datesette, sqlite, fly.io, love, and tears | #top