{"id":4852,"library":"wonderwords","title":"Wonderwords","description":"Wonderwords is a Python library for generating random English words and structured sentences. It also includes a command-line interface. Currently at version 3.0.1, it maintains an active development and release cadence, with significant updates between major versions.","status":"active","version":"3.0.1","language":"en","source_language":"en","source_url":"https://github.com/mrmaxguns/wonderwordsmodule","tags":["word generation","natural language","random","cli"],"install":[{"cmd":"pip install wonderwords","lang":"bash","label":"Install stable version"},{"cmd":"pip install wonderwords[cli]","lang":"bash","label":"Install with CLI dependencies (Rich for colorized output)"}],"dependencies":[{"reason":"Optional dependency for colorized command-line interface output.","package":"rich","optional":true}],"imports":[{"note":"The `RandomWord` class encapsulates word generation functionality.","symbol":"RandomWord","correct":"from wonderwords import RandomWord"},{"note":"The `RandomSentence` class provides methods for generating random sentences.","symbol":"RandomSentence","correct":"from wonderwords import RandomSentence"},{"note":"Used to access default word lists for custom categories, e.g., Defaults.NOUNS.","symbol":"Defaults","correct":"from wonderwords import Defaults"}],"quickstart":{"code":"from wonderwords import RandomWord, RandomSentence\n\nrw = RandomWord()\n\n# Generate a random word\nword = rw.word()\nprint(f\"Random word: {word}\")\n\n# Generate a random word that starts with 'a' and is an adjective\nadj_word = rw.word(starts_with=\"a\", include_categories=[\"adjective\"])\nprint(f\"Adjective starting with 'a': {adj_word}\")\n\n# Generate a list of 5 words that are nouns\nnoun_list = rw.words_list(amount=5, include_categories=[\"noun\"])\nprint(f\"5 random nouns: {noun_list}\")\n\nrs = RandomSentence()\n\n# Generate a simple sentence\nsentence = rs.simple_sentence()\nprint(f\"Simple sentence: {sentence}\")","lang":"python","description":"This quickstart demonstrates how to initialize `RandomWord` and `RandomSentence` objects to generate individual words, filtered words, lists of words, and simple sentences."},"warnings":[{"fix":"Review the v2.0.0 and v2.2.0 changelogs and documentation. If using custom categories, ensure you are on v2.2.0 or newer, where they are passed as keyword arguments to `RandomWord`.","message":"Version 2.0.0 introduced significant API refactoring, including naming convention changes and a new object-oriented model. Migrating from v1.x will likely require code adjustments. Additionally, v2.0.0 initially removed support for custom word categories, restricting generation to 'nouns', 'verbs', and 'adjectives'. Custom categories were re-introduced in v2.2.0.","severity":"breaking","affected_versions":"From v1.x to v2.0.0, and v2.0.0 to v2.2.0 (for custom categories)."},{"fix":"Use `include_categories` instead. For example, `rw.word(include_categories=[\"noun\"])`.","message":"The `include_parts_of_speech` argument in methods like `word()` is deprecated and will be removed in future versions.","severity":"deprecated","affected_versions":"v2.x, v3.x"},{"fix":"Loosen filtering criteria or set `return_less_if_necessary=True` when calling `words_list()` if you anticipate fewer matches than requested.","message":"The `NoWordsToChoseFrom` exception is raised if your filtering criteria (e.g., `starts_with`, `ends_with`, `word_min_length`, `include_categories`) are too restrictive, or if the requested `amount` of words in `words_list()` exceeds the number of available words matching the criteria.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Create a single instance of `RandomWord` or `RandomSentence` at the top level of your module or application and reuse it across your code to optimize performance.","message":"Word lists are loaded once per `RandomWord` or `RandomSentence` instance. Creating multiple instances unnecessarily can introduce performance overhead during initialization, especially if you create them repeatedly within a loop or function.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}