nameof
Get the name of a variable or attribute, as in C#
Decision gist · record as of 2026-08-14
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.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- The argument must be a variable or attribute; does not work in the presence of AST-modifying tools like pytest.
- 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 · maintenance · safety
MIT (permissive) — MIT license permits commercial and private use with minimal restrictions, requiring only license and copyright notice retention.
last release 2020-02-01 (2386 days) · last repo commit 2024-12-07 · 18 stars · archived
0 known vulnerabilities (OSV.dev, 2026-08-14) · 208,877 downloads/mo, #9,523 on PyPI
Alternatives
Verify before relying
pip install nameof
from nameof import nameof
assert nameof(foo) == "foo"
assert nameof(foo.bar) == "bar"- 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
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 on this page. Verify before relying on it.
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
nameof on PyPI
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.
The argument must be a variable or attribute; does not work in the presence of AST-modifying tools like pytest.
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"
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 | Not specified |
| Install friction | High. Source build required |
| Runtime dependencies | None |
| Maintenance | Abandoned 2,386 days since the last release |
| Last repo commit | repository archived |
| First released | |
| Downloads | 208,877 / month, #9,523 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | License :: OSI Approved :: MIT LicenseProgramming Language :: PythonProgramming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8 |
Evidence: nameof-0.0.1.tar.gz
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “get variable name as string”
- nameofRetrieves the name of a variable or attribute as a string at runtime…
- varnameRetrieves variable names at runtime from inside functions and…
- namedProvides utilities to inspect and work with Python type names and…
Give your agent the search over MCP, or paste the wish link into any chat.
More Software Development packages
Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.
Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.
Install it if you are building CLIs in Python.
Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.
See also varname · executing · typing-inspect · typing-inspection · attributes-doc · read-version · qualname · grpcio-reflection · snoop · inspect2