Skip to content

Instantly share code, notes, and snippets.

@Tattoo
Created April 11, 2019 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tattoo/31ba06cdd374c5d09165c2817bc13d7f to your computer and use it in GitHub Desktop.
Save Tattoo/31ba06cdd374c5d09165c2817bc13d7f to your computer and use it in GitHub Desktop.
Some fake data generation in Python 3
from decimal import Decimal
from pprint import pprint
from random import choice, choices, randint
def random_digits(n):
"""Returns int with length `n`"""
start = 10**(n-1)
end = (10**n)-1
return randint(start, end)
def random_precision(x, y):
"""return string of a decimal which in total is of length `x` with `y` places after radix point"""
return str(Decimal(random_digits(x))/(10**y)) # very big `x` must be Decimals instead of normal floats!
# characters Harrison-Stetson'ed from: http://www.columbia.edu/~fdc/utf8/index.html#notes
# selection around the world
CHARS='abcdefghijklmnopqrstuvwxyzχçéñônàășíåðæøäöëüзыянõēęžłıħġ我べ않아요'.upper()
pprint([
random_digits(7),
random_precision(23, 2),
(lambda n: ''.join(choices(CHARS, k=n)))(255),
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment