{"id":1583,"library":"num2words","title":"Num2Words","description":"Num2Words is a Python library designed to convert numerical values into their word representations across multiple languages. It supports various output formats, including cardinal numbers (e.g., 'forty-two'), ordinal numbers (e.g., 'forty-second'), years, and currency representations with appropriate localization. The library is currently active, with the latest stable version being 0.5.14, and receives regular updates, primarily focusing on adding new language support and fixing existing localizations.","status":"active","version":"0.5.14","language":"en","source_language":"en","source_url":"https://github.com/savoirfairelinux/num2words","tags":["number-to-word","localization","internationalization","currency","text-conversion"],"install":[{"cmd":"pip install num2words","lang":"bash","label":"Install latest stable version"}],"dependencies":[{"reason":"Used for the command-line interface (CLI) utility. Not strictly required for programmatic library usage.","package":"docopt","optional":true}],"imports":[{"symbol":"num2words","correct":"from num2words import num2words"}],"quickstart":{"code":"from num2words import num2words\n\n# Basic cardinal conversion (default)\nprint(num2words(42)) # forty-two\n\n# Ordinal conversion\nprint(num2words(42, to='ordinal')) # forty-second\n\n# Ordinal number conversion\nprint(num2words(42, to='ordinal_num')) # 42nd\n\n# Currency conversion (defaults to 'dollar' or 'euro' based on language)\nprint(num2words(1234.56, to='currency', currency='USD')) # one thousand, two hundred and thirty-four dollars, fifty-six cents\n\n# French language conversion\nprint(num2words(42, lang='fr')) # quarante-deux","lang":"python","description":"This quickstart demonstrates how to import the `num2words` function and use it for various conversion types, including cardinal, ordinal, ordinal number, and currency formats, as well as specifying a target language."},"warnings":[{"fix":"Replace `ordinal=True` with `to='ordinal'` or `to='ordinal_num'`.","message":"The `ordinal` boolean argument (e.g., `num2words(42, ordinal=True)`) was replaced by the `to` argument with values like `'ordinal'` or `'ordinal_num'` in later 0.5.x versions. Using the old `ordinal=True` may lead to unexpected behavior or errors in current versions.","severity":"breaking","affected_versions":"<=0.5.x (prior to comprehensive `to` argument)"},{"fix":"Ensure you are using a safe version (e.g., 0.5.14 or earlier safe versions). If you installed 0.5.15 or 0.5.16, downgrade immediately and audit your systems for compromise.","message":"PyPI versions 0.5.15 and 0.5.16 of `num2words` were compromised with 'Scavenger Malware' in July 2025 due to a phishing attack on maintainers. These versions contained malicious code and were removed from PyPI. **Do not install or use these specific versions.**","severity":"breaking","affected_versions":"0.5.15, 0.5.16"},{"fix":"Implement a fallback mechanism, such as a `try-except NotImplementedError` block, to default to English or another supported language if the requested language is unavailable.","message":"Attempting to convert a number to a language that is not supported will raise a `NotImplementedError`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Review the output for critical applications, especially when using less common languages or complex number formats. Check GitHub issues for known language-specific problems.","message":"While `num2words` supports many languages, some language localizations, particularly for ordinal numbers or complex grammatical rules (e.g., Arabic, Korean, Amharic), may still contain bugs or inaccuracies.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}