Skip to content

Instantly share code, notes, and snippets.

@Erenor
Last active February 16, 2020 15:15
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 Erenor/e205fcdda5e80bf333a6931c62b783f1 to your computer and use it in GitHub Desktop.
Save Erenor/e205fcdda5e80bf333a6931c62b783f1 to your computer and use it in GitHub Desktop.
[PYTHON 3.6] A simple class used to create random names based on syllables dictionaries
# Needed built-in modules
import random
# Randomic names for "whatever"
class MyRandomName:
"""Class used to create randomized names based on syllables-ish lists
Tested with Python 3.6
See: https://pyfiddle.io/fiddle/ea12ddcc-d989-4d87-9a62-836aa1e4b624/?i=true
"""
# List of starting terms
nameStart = ['A', 'An', 'Ae', 'Ba', 'Dir', 'Gam', 'Hu', 'Ka', 'Me', 'Mow', 'Os', 'Un', 'Wyu', 'Zo']
# List of terms in the middle of the name (can be empty)
nameMiddle = ['', 'ba', 'cor', 'cae', 'da', 'du', 'lau', 'lon', 'ma', 'na', 'nor', 'pes', 'puu', 'rao', 'ren', 'ro', 'san', 'son', 'sun', 'sur', 'sut', 'ta', 'tex', 'tos', 'ven', ]
# List of terms at the end of the name
nameEnd = ['cae', 'da', 'dir', 'du', 'e', 'ean', 'eh', 'ee', 'cor', 'hu', 'ka', 'lau', 'lon', 'ma', 'me', 'mow', 'na', 'nor', 'os', 'pes', 'puu', 'rao', 'ren', 'ro', 'san', 'son', 'sun', 'sur', 'sut', 'ta', 'tex', 'tos', 'ven', 'wyu', 'zo']
@classmethod
def get_random_name(cls):
return (
cls.nameStart[random.randint(0, len(cls.nameStart) - 1)]
+ cls.nameMiddle[random.randint(0, len(cls.nameMiddle) - 1)]
+ cls.nameEnd[random.randint(0, len(cls.nameEnd) - 1)]
)
# And this is an example of how to use the class
for i in range(0, 10):
print (MyRandomName.get_random_name())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment