DEV Community

D Smith
D Smith

Posted on

Silly Name Generator

Table of Contents

  1. Introduction
  2. Name Lists
    1. First Names
    2. Last Names
  3. Choosing a Name
  4. Main

Introduction

This is the first of the Impractical Python book by Lee Vaughan.
I aim to do every project in this book, as a literate program in my own style.
As such please be kind, I am only a hobbyist that is aiming to learn.

Name Lists

First Names

First things first, pun intended.
We need to have a list for the python program to choose from.
In python its easiest to do that with a list or tuple. The book used a tuple as it never
changes durring execution so there is no need for a list.
Admittedly I copy-pasted this section and the last names because I did not want to type them all.

firstnames = ('Baby Oil', 'Bad News', 'Big Burps', "Bill 'Beenie-Weenie'",
     "Bob 'Stinkbug'", 'Bowel Noises', 'Boxelder', "Bud 'Lite' ",
     'Butterbean', 'Buttermilk', 'Buttocks', 'Chad', 'Chesterfield',
     'Chewy', 'Chigger', 'Cinnabuns', 'Cleet', 'Cornbread', 'Crab Meat',
     'Crapps', 'Dark Skies', 'Dennis Clawhammer', 'Dicman', 'Elphonso',
     'Fancypants', 'Figgs', 'Foncy', 'Gootsy', 'Greasy Jim', 'Huckleberry',
     'Huggy', 'Ignatious', 'Jimbo', "Joe 'Pottin Soil'", 'Johnny',
     'Lemongrass', 'Lil Debil', 'Longbranch', '"Lunch Money"', 'Mergatroid',
     '"Mr Peabody"', 'Oil-Can', 'Oinks', 'Old Scratch', 'Ovaltine',
     'Pennywhistle', 'Pitchfork Ben', 'Potato Bug', 'Pushmeet',
     'Rock Candy', 'Schlomo', 'Scratchensniff', 'Scut',
     "Sid 'The Squirts'", 'Skidmark', 'Slaps', 'Snakes', 'Snoobs',
     'Snorki', 'Soupcan Sam', 'Spitzitout', 'Squids', 'Stinky',
     'Storyboard', 'Sweet Tea', 'TeeTee', 'Wheezy Joe',
     "Winston 'Jazz Hands'", 'Worms')

Last Names

Same idea as firstnames. But for last names!

lastnames = ('Appleyard', 'Bigmeat', 'Bloominshine', 'Boogerbottom',
    'Breedslovetrout', 'Butterbaugh', 'Clovenhoof', 'Clutterbuck',
    'Cocktoasten', 'Endicott', 'Fewhairs', 'Gooberdapple', 'Goodensmith',
    'Goodpasture', 'Guster', 'Henderson', 'Hooperbag', 'Hoosenater',
    'Hootkins', 'Jefferson', 'Jenkins', 'Jingley-Schmidt', 'Johnson',
    'Kingfish', 'Listenbee', "M'Bembo", 'McFadden', 'Moonshine', 'Nettles',
    'Noseworthy', 'Olivetti', 'Outerbridge', 'Overpeck', 'Overturf',
    'Oxhandler', 'Pealike', 'Pennywhistle', 'Peterson', 'Pieplow',
    'Pinkerton', 'Porkins', 'Putney', 'Quakenbush', 'Rainwater',
    'Rosenthal', 'Rubbins', 'Sackrider', 'Snuggleshine', 'Splern',
    'Stevens', 'Stroganoff', 'Sugar-Gold', 'Swackhamer', 'Tippins',
    'Turnipseed', 'Vinaigrette', 'Walkingstick', 'Wallbanger', 'Weewax',
    'Weiners', 'Whipkey', 'Wigglesworth', 'Wimplesnatch', 'Winterkorn',
    'Woolysocks')

Choosing a Name

To choose things, we need to use python's random module.
Random does lots of neat things in generating sudo random numbers.
Random.choice is what were gonna use for this one.

import random

After the names are choosen, they are returned so that they can be displayed.

def chooser(firstnames,lastnames):
    firstname = random.choice(firstnames)
    lastname = random.choice(lastnames)
    return (firstname, lastname)

Main

Finally, we put it all together.
Technically, I should hafve written a "main" block, but this will work instead.
Chooser is outside incase you need it for something.

In essence, this program picks two names from a random list, returns them to the variables
firstname and lastname, then prints them.

Personally I think the original author used to many newlines, but whatever.

# Check sillyname.org for details
 # Imports
import sys
import random

# Internal Functions
def chooser(firstnames,lastnames):
    firstname = random.choice(firstnames)
    lastname = random.choice(lastnames)
    return (firstname, lastname)




# Main script




def main():
    print("Welcome to the Pysch 'side kick name picker'!\n")
    print("A name just like Sean would pick for Gus:\n\n")
    firstnames = ('Baby Oil', 'Bad News', 'Big Burps', "Bill 'Beenie-Weenie'",
     "Bob 'Stinkbug'", 'Bowel Noises', 'Boxelder', "Bud 'Lite' ",
     'Butterbean', 'Buttermilk', 'Buttocks', 'Chad', 'Chesterfield',
     'Chewy', 'Chigger', 'Cinnabuns', 'Cleet', 'Cornbread', 'Crab Meat',
     'Crapps', 'Dark Skies', 'Dennis Clawhammer', 'Dicman', 'Elphonso',
     'Fancypants', 'Figgs', 'Foncy', 'Gootsy', 'Greasy Jim', 'Huckleberry',
     'Huggy', 'Ignatious', 'Jimbo', "Joe 'Pottin Soil'", 'Johnny',
     'Lemongrass', 'Lil Debil', 'Longbranch', '"Lunch Money"', 'Mergatroid',
     '"Mr Peabody"', 'Oil-Can', 'Oinks', 'Old Scratch', 'Ovaltine',
     'Pennywhistle', 'Pitchfork Ben', 'Potato Bug', 'Pushmeet',
     'Rock Candy', 'Schlomo', 'Scratchensniff', 'Scut',
     "Sid 'The Squirts'", 'Skidmark', 'Slaps', 'Snakes', 'Snoobs',
     'Snorki', 'Soupcan Sam', 'Spitzitout', 'Squids', 'Stinky',
     'Storyboard', 'Sweet Tea', 'TeeTee', 'Wheezy Joe',
     "Winston 'Jazz Hands'", 'Worms')

    lastnames = ('Appleyard', 'Bigmeat', 'Bloominshine', 'Boogerbottom',
    'Breedslovetrout', 'Butterbaugh', 'Clovenhoof', 'Clutterbuck',
    'Cocktoasten', 'Endicott', 'Fewhairs', 'Gooberdapple', 'Goodensmith',
    'Goodpasture', 'Guster', 'Henderson', 'Hooperbag', 'Hoosenater',
    'Hootkins', 'Jefferson', 'Jenkins', 'Jingley-Schmidt', 'Johnson',
    'Kingfish', 'Listenbee', "M'Bembo", 'McFadden', 'Moonshine', 'Nettles',
    'Noseworthy', 'Olivetti', 'Outerbridge', 'Overpeck', 'Overturf',
    'Oxhandler', 'Pealike', 'Pennywhistle', 'Peterson', 'Pieplow',
    'Pinkerton', 'Porkins', 'Putney', 'Quakenbush', 'Rainwater',
    'Rosenthal', 'Rubbins', 'Sackrider', 'Snuggleshine', 'Splern',
    'Stevens', 'Stroganoff', 'Sugar-Gold', 'Swackhamer', 'Tippins',
    'Turnipseed', 'Vinaigrette', 'Walkingstick', 'Wallbanger', 'Weewax',
    'Weiners', 'Whipkey', 'Wigglesworth', 'Wimplesnatch', 'Winterkorn',
    'Woolysocks')
    while True:
    firstname, lastname = chooser(firstnames, lastnames)
    print("{} {}".format(firstname, lastname, file=sys.stderr))
    print("\n\n")

    try_again=input("\n\nTry again? (press n to quit)\n")
    if try_again.lower() == 'n':
        break

    input("press Enter to exit")



if __name__ == '__main__':
    main()
    sys.exit()

to use it, justt run sillyname.py from the commandline.
like so:

./sillyname.py

ant it will output something like this:

./sillyname.py
Welcome to the Pysch 'side kick name picker'!

A name just like Sean would pick for Gus:


Chesterfield Sugar-Gold





Try again? (press n to quit)

Overall, I hope you enjoyed this little read.

Top comments (4)

Collapse
 
marissab profile image
Marissa B • Edited

I dig it! A potential addition to up the ante if you're interested in applying what you did here again -- try to generate the pools of first names and last names using a series of syllables before putting the first and last names together. Kinda adds another layer to the project using the same principle.

I'll be doing something similar to generate names for a D&D app since I'm awful at coming up with character names on the fly.

Collapse
 
zeeter profile image
D Smith

That does sound like a cool idea. I feel like it would just be an extension of the same principle.

Collapse
 
malywonsz profile image
maly_wonsz

Look at this: github.com/joke2k/faker

Collapse
 
zeeter profile image
D Smith

That is really cool!
I might add that into some of my projects.