Reading a local word list

If you're doing this repeatedly, I would download it locally and pull from the local file. *nix users can use /usr/share/dict/words.

Example:

word_file = "/usr/share/dict/words"
WORDS = open(word_file).read().splitlines()

Pulling from a remote dictionary

If you want to pull from a remote dictionary, here are a couple of ways. The requests library makes this really easy (you'll have to pip install requests):

import requests

word_site = "https://www.mit.edu/~ecprice/wordlist.10000"

response = requests.get(word_site)
WORDS = response.content.splitlines()

Alternatively, you can use the built in urllib2.

import urllib2

word_site = "https://www.mit.edu/~ecprice/wordlist.10000"

response = urllib2.urlopen(word_site)
txt = response.read()
WORDS = txt.splitlines()
Answer from Kyle Kelley on Stack Overflow
Top answer
1 of 8
122

Reading a local word list

If you're doing this repeatedly, I would download it locally and pull from the local file. *nix users can use /usr/share/dict/words.

Example:

word_file = "/usr/share/dict/words"
WORDS = open(word_file).read().splitlines()

Pulling from a remote dictionary

If you want to pull from a remote dictionary, here are a couple of ways. The requests library makes this really easy (you'll have to pip install requests):

import requests

word_site = "https://www.mit.edu/~ecprice/wordlist.10000"

response = requests.get(word_site)
WORDS = response.content.splitlines()

Alternatively, you can use the built in urllib2.

import urllib2

word_site = "https://www.mit.edu/~ecprice/wordlist.10000"

response = urllib2.urlopen(word_site)
txt = response.read()
WORDS = txt.splitlines()
2 of 8
20

Solution for Python 3

For Python3 the following code grabs the word list from the web and returns a list. Answer based on accepted answer above by Kyle Kelley.

import urllib.request

word_url = "http://svnweb.freebsd.org/csrg/share/dict/words?view=co&content-type=text/plain"
response = urllib.request.urlopen(word_url)
long_txt = response.read().decode()
words = long_txt.splitlines()

Output:

>>> words
['a', 'AAA', 'AAAS', 'aardvark', 'Aarhus', 'Aaron', 'ABA', 'Ababa',
 'aback', 'abacus', 'abalone', 'abandon', 'abase', 'abash', 'abate',
 'abbas', 'abbe', 'abbey', 'abbot', 'Abbott', 'abbreviate', ... ]

And to generate (because it was my objective) a list of 1) upper case only words, 2) only "name like" words, and 3) a sort-of-realistic-but-fun sounding random name:

import random
upper_words = [word for word in words if word[0].isupper()]
name_words  = [word for word in upper_words if not word.isupper()]
rand_name   = ' '.join([name_words[random.randint(0, len(name_words))] for i in range(2)])

And some random names:

>>> for n in range(10):
        ' '.join([name_words[random.randint(0,len(name_words))] for i in range(2)])

    'Semiramis Sicilian'
    'Julius Genevieve'
    'Rwanda Cohn'
    'Quito Sutherland'
    'Eocene Wheller'
    'Olav Jove'
    'Weldon Pappas'
    'Vienna Leyden'
    'Io Dave'
    'Schwartz Stromberg'
Discussions

xml - How can I create a Word document using Python? - Stack Overflow
I'd like to create a Word document using Python, however, I want to re-use as much of my existing document-creation code as possible. I am currently using an XSLT to generate an HTML file that I programatically convert to a PDF file. However, my client is now requesting that the same document be made available in ... More on stackoverflow.com
🌐 stackoverflow.com
Generate random word of specific length
Another option you could look at is xkcdpass . More on reddit.com
🌐 r/learnpython
26
4
November 15, 2022
python - Generating random words - Stack Overflow
I'm trying to create a string that has a set amount of different words I include in a list, however the code I use only uses one word at random, not a different word for every word printed. This i... More on stackoverflow.com
🌐 stackoverflow.com
Simple word generator written in Python

maybe i'm the stupid one here, but how do i run the thing?

More on reddit.com
🌐 r/conlangs
35
45
August 8, 2017
🌐
Reddit
reddit.com › r/learnpython › python word doc generation
r/learnpython on Reddit: Python Word Doc Generation
September 17, 2023 -

I work in a legal department that’s been having a lot of issues with how our contracts are being generation out of SFDC by our sales team. Working with the SFDC (Salesforce) developer team is a pain and takes months for any solutions to be implemented.

Is it possible for me to use a Python script that takes an active word document, strips information found in certain locations of the doc, and then generates a new (and correct) word document from a presaved template. In essence, the wrong contract template is being generated from sales and I want a Python script to automate the manual adjustments we’ve been having to make. Thanks so much in advance!

🌐
Blogger
dwmallisk.blogspot.com › 2014 › 10 › using-python-random-functions-to-create.html
Dave's tech docs: Using Python random functions to create new words
October 17, 2014 - For example, if you are expecting a baby, why not give him or her an original name, such as "Depgarf?" Figure 4 shows how you can use Python random functions and concatenation to create a two-, three-, four-, or five-syllable new, random word. ... The 'w = random.randint(2,5)' statement assigns an integer value, 2 through 5, to variable w.
🌐
Bobby Hadz
bobbyhadz.com › blog › python-generate-random-word
How to generate random Words or Letters in Python | bobbyhadz
Copied!import random import requests def get_list_of_words(): response = requests.get( 'https://www.mit.edu/~ecprice/wordlist.10000', timeout=10 ) string_of_words = response.content.decode('utf-8') list_of_words = string_of_words.splitlines() return list_of_words words = get_list_of_words() print(words) random_word = random.choice(words) print(random_word) # 👉️ zoo ... If you don't have the requests module installed, install it by running the following command. ... Copied!# 👇️ In a virtual environment or using Python 2 pip install requests # 👇️ For python 3 (could also be pip3.10 depending on your version) pip3 install requests
🌐
Medium
piero-paialunga.medium.com › hands-on-new-words-generation-app-with-machine-learning-using-python-cd5095649851
Hands on New Words Generation App with Machine Learning, using Python | by Piero Paialunga | Medium
March 16, 2023 - Let’s say you already have Python. What do we need to run this app? ... That’s it. Impressive right? You can download streamlit running this code: ... Veeeery easy. ... The only thing you should care about is that you have an OpenAI API. To do that, please follow the instructions here (OpenAI API). The code is very easy and uploaded in a public Github folder (https://github.com/PieroPaialungaAI/new_word_generator).
Find elsewhere
🌐
GitHub
github.com › TUR1ACUS › Document-Generator
GitHub - TUR1ACUS/Document-Generator: This Python script utilizes the docxtpl module to generate customized Word documents. · GitHub
This Python script utilizes the docxtpl module to generate customized Word documents (.docx) from a predefined template and data provided in a CSV file.
Author   TUR1ACUS
🌐
GitHub
github.com › vaibhavsingh97 › random-word
GitHub - vaibhavsingh97/random-word: This is a simple python package to generate random english words
This is a simple python package to generate random English words.
Starred by 126 users
Forked by 24 users
Languages   Python 91.7% | Makefile 8.3% | Python 91.7% | Makefile 8.3%
🌐
DEV Community
dev.to › lubiah › generating-random-words-in-python-2obi
Generating random words in python - DEV Community
September 10, 2021 - It contains a collection of string constants import random #Python's module for generating random objects lowercase_letters = string.ascii_lowercase #A constant containing lowercase letters uppercase_letters = string.ascii_uppercase #A constant containing uppercase letters def uppercase_word(): #The function responsible for generating #random words which are in uppercase word = '' #The variable which will hold the random word random_word_length = random.randint(1,10) #The random length of the word while len(word) != random_word_length: #While loop word += random.choice(uppercase_letters) return word
🌐
Quora
quora.com › How-do-you-create-a-random-list-of-words-in-Python
How to create a random list of words in Python - Quora
Answer (1 of 3): t̲h̲i̲s̲ ̲d̲e̲m̲o̲n̲s̲t̲r̲a̲t̲e̲s̲ ̲-̲ ̲A̲l̲ri̲g̲h̲t̲ ̲,̲ ̲t̲o̲ c̲r̲e̲a̲t̲e̲ ̲a̲ ̲r̲a̲nd̲o̲m̲ ̲l̲i̲s̲t̲ ̲of̲ ̲w̲o̲rd̲s̲ ̲i̲n̲ ̲P̲y̲t̲h̲o̲n ̲,̲ ̲y̲o̲u̲’̲l̲l̲ ̲f̲i̲r̲s̲t ̲n̲e̲e̲d̲ ̲a̲ ...
🌐
Readthedocs
wonderwords.readthedocs.io › en › latest › quickstart.html
Quickstart - Wonderwords documentation - Read the Docs
Wonderwords is a lightweight python tool that can be used to generate random words and sentences. In this tutorial you will learn the basics of Wonderwords and the command line interface. This tutorial is meant for those who have never used Wonderwords or those who want to learn more about it.
🌐
Perfect Doc Studio
perfectdoc.studio › home › how to generate word documents using python: step-by-step guide
How to Generate Word Documents Using Python
December 5, 2025 - It is accessible even to novices in Python. In this guide, we’ll walk you through everything you need to know about populating Word templates with data using Python. Prerequisites for automating document generation with Python: Word template, Excel Data, pandas, openpyxl, and docxtpl.
🌐
PyTutorial
pytutorial.com › python-docx-tutorial-create-word-documents
PyTutorial | Python-docx Tutorial: Create Word Documents
November 8, 2025 - Learn how to create Word documents step by step using Python-docx library with practical examples for paragraphs, tables, formatting, and document structure.
🌐
Reddit
reddit.com › r/learnpython › generate random word of specific length
r/learnpython on Reddit: Generate random word of specific length
November 15, 2022 -

I want to generate a random word of a specific length. I found a python module called random-word and this is my code.

from random_word import RandomWords
r = RandomWords()

# Return a single random word
r.get_random_word()

result = None
while result is None:
    try:
        word1 = r.get_random_word()
        print (word1)
        if len(word1) == 5:
            result = True
    except:
         print ('There was a problem')
# other code that uses result but is not involved in getting it

print (word1)
print (len(word1))

It works perfectly fine, but it's very slow. It takes about 10 to 15 seconds to run until it finds a word of that length. Does anybody have a better way of doing this? Another way I thought was to maybe have a dictionary file and iterate through that. The reason I don't like that approach is I don't really like the idea of having to have a file on the machine. Also if it iterates through the file it won't be random.

Any suggestions appreciated.

Thanks

🌐
Quora
quora.com › How-do-you-generate-a-random-word-from-a-list-in-Python
How to generate a random word from a list in Python - Quora
Answer (1 of 3): There is something called choice function in the random module of Python. You can use it the following way. [code]import random word_list = ['apple','banana','cherry','dates','etc'] random.choice(word_list) [/code]This gives you a random word from a list in Python. Also, in Py...
🌐
Plain English
plainenglish.io › blog › how-to-generate-automated-word-documents-with-python-d6b7f6d3f801
How to Generate Automated Word Documents with Python
May 17, 2022 - Luckily there’s a package to remedy our predicament — python-docx. If you haven’t already perused their documentation, then I highly advise you to do so. It is quite possibly one of the most intuitive and self-explanatory APIs I have worked with in recent times. It allows you to automate document generation by inserting text, filling in tables, and rendering images into your report on demand.
🌐
Read the Docs
python-docx.readthedocs.io › en › latest
python-docx — python-docx 1.2.0 documentation
Release v1.2.0 (Installation) python-docx is a Python library for creating and updating Microsoft Word (.docx) files. Here’s an example of what python-docx can do: Installing · Quickstart · Working with Documents · Working with Tables · Working with Text ·
🌐
Reddit
reddit.com › r/conlangs › simple word generator written in python
r/conlangs on Reddit: Simple word generator written in Python
August 8, 2017 -

https://github.com/Lebed-kun/simple-conlang-generator/blob/patch-1/conlang_generator.py

This word generator can create any amount of words with user-defined phonemic patterns considering user-defined forbidden phonemic sequences

Further changes:

  • Add user-defined changes of resulted words using phonemic notation (X > Y / Z , where X is a source phoneme(s), Y - a resulting phoneme(s), Z - is a condition for phonemic shift (optional))

  • Use randomly generated or user-defined frequencies of phonemes for word generating (because phonemes aren't equiprobable in any spoken language)

  • Add randomly generated sound changes and phonotactics

  • Add user-defined and randomly generated (derivational) morphology

  • Add semantics

UPD: https://github.com/Lebed-kun/simple-conlang-generator/blob/master/conlang_generator.py

Now you can set sound changes (in phonological rule notation) and apply them to words. Also phonemes, forbidden clusters and sound changes are saved in a single file