--- id: nameof version: "0.0.1" license: MIT license_treatment: permissive maintenance: abandoned --- # nameof — Get the name of a variable or attribute, as in C# License: permissive · Maintenance: abandoned · Downloads: 208.9K/mo ## What it is and what it does nameof is a utility that extracts the string name of a variable or object attribute at runtime by inspecting the abstract syntax tree (AST). It attempts to replicate C#'s nameof operator, allowing code like `nameof(foo)` to return the string `"foo"`. The package has no runtime dependencies and consists of minimal code that can be copied directly into a project if needed. However, the author explicitly states this was a toy project and recommends using an alternative instead. The package is abandoned, with its repository archived and no releases since 2020-02-01. It relies on fragile AST manipulation that breaks in the presence of other AST-modifying tools like pytest, and the author cautions that code depending on it should be thoroughly tested. It is not suitable for production use. Use it for: - Debugging and logging where you need to print variable names alongside their values - Generating field names dynamically in data validation or ORM frameworks - Building introspection tools that require mapping runtime objects back to their source variable names ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Retrieves the name of a variable or attribute as a string at runtime through AST inspection, mimicking C# nameof functionality. No. The author explicitly recommends against this package in the description. The project is abandoned, last released 2020-02-01, and relies on fragile AST inspection that breaks with common tools. High install friction and lack of maintenance make it unsuitable for any new project. ## Install pip install nameof uv add nameof poetry add nameof ## Installing nameof Before you install: High install friction. The package is abandoned (repository archived, last release 2020-02-01) and the author explicitly recommends switching to an alternative instead. License in practice: MIT license permits commercial and private use with minimal restrictions, requiring only license and copyright notice retention. Quickstart: pip install nameof from nameof import nameof assert nameof(foo) == "foo" assert nameof(foo.bar) == "bar" The argument must be a variable or attribute; does not work in the presence of AST-modifying tools like pytest. Verify before relying: - Whether the package works reliably with Python versions beyond 3.8 - Specific AST-based limitations beyond pytest and birdseye that may affect usage - Whether the recommended alternative is a drop-in replacement or requires code changes ## Package facts - License: MIT (permissive) - Python support: unspecified - Install friction: high - Maintenance: abandoned - Downloads: 208.9K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags get variable name as string, nameof functionality python, variable name introspection, attribute name reflection, runtime variable naming, ast-introspection, abandoned [View on SkillFed](https://skillfed.io/packages/nameof) · [View on PyPI](https://pypi.org/project/nameof/)