Registry / serialization / inflection

inflection

JSON →
library0.5.1pypypi✓ verified 25d ago

Inflection is a Python library that provides string transformation utilities, porting the functionality of Ruby on Rails' inflector. It handles pluralization, singularization, and various case conversions like CamelCase to snake_case. The current version is 0.5.1, released in August 2020, indicating an irregular release cadence and a maintenance status.

pip install inflection
INSTALL
IMPORT
SIG · INFLECTION
I
inflection
serializationpythonv0.5.1
Install
1.7s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.5.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.7s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

camelize
import inflection inflection.camelize('device_type')
underscore
import inflection inflection.underscore('DeviceType')
pluralize
import inflection inflection.pluralize('cat')
singularize
import inflection inflection.singularize('cats')
dasherize
import inflection inflection.dasherize('puni_puni')
humanize
import inflection inflection.humanize('employee_salary')
ordinalize
import inflection inflection.ordinalize(1)
tableize
import inflection inflection.tableize('fancy_category')
titleize
import inflection inflection.titleize('man from the boondocks')
transliterate
import inflection inflection.transliterate('你好')

The quickstart demonstrates basic string transformations: `camelize` for case conversion, `pluralize` for converting singular words to their plural form, and `singularize` for converting plurals to singulars.

import inflection # Convert a snake_case string to CamelCase result_camel = inflection.camelize("my_variable_name") print(f"CamelCase: {result_camel}") # Pluralize a word result_plural = inflection.pluralize("mouse") print(f"Plural: {result_plural}") # Singularize a word result_singular = inflection.singularize("data") print(f"Singular: {result_singular}")
Debug
Known issues
breakingVersion 0.4.0 dropped support for Python 2.x (2.6, 2.7) and older Python 3.x versions (3.3, 3.4), as well as PyPy. The library now requires Python 3.5 or newer. Ensure your environment meets this requirement before upgrading or using.
fix
Upgrade to Python 3.5+ or pin the `inflection` version to <0.4.0 for older Python environments.
affects: 0.4.0 and later
gotchaThe `pluralize` and `singularize` functions are specifically designed for English words and may not produce correct results for other languages. The library is a direct port of Ruby on Rails' inflector, which primarily targets English.
fix
Use a dedicated internationalization (i18n) library for pluralization and singularization in non-English languages.
affects: All versions
gotchaThe `camelize()` function defaults to `uppercase_first_letter=True`, resulting in `UpperCamelCase`. If `lowerCamelCase` is desired, you must explicitly set this parameter to `False`. For example, `inflection.camelize('foo_bar', False)` returns 'fooBar'.
fix
Specify `uppercase_first_letter=False` in `camelize()` calls if `lowerCamelCase` is intended.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'inflection'
The 'inflection' library is not installed in your Python environment or the Python interpreter cannot find it.
fix
Install the library using pip: `pip install inflection`
AttributeError: module 'inflection' has no attribute 'pluralise'
You are trying to call a method that does not exist or is misspelled. The library uses 'pluralize' (American English spelling), not 'pluralise'.
fix
Correct the method name to the accurate spelling, e.g., `inflection.pluralize('word')`
NameError: name 'inflection' is not defined
This typically occurs when you've imported specific functions from the 'inflection' module (e.g., `from inflection import pluralize`) but then try to access them via the module name as if the entire module was imported (e.g., `inflection.pluralize`).
fix
Either import the entire module (`import inflection`) or call the function directly without the module prefix (`pluralize('word')` after `from inflection import pluralize`).
TypeError: expected string or bytes-like object
An 'inflection' function was called with an argument of an incorrect type, such as an integer or a list, when it expected a string.
fix
Ensure that the input provided to the 'inflection' function is a string, converting it if necessary: `inflection.pluralize(str(123))`
Upgrade
Version history
0.5.1latest on PyPI · released Aug 22, 2020
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
Resources
inflection — pip install inflection · libregistry