On this page
  1. inspect.getmodulename
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

inspect.getmodulename

Prev: inspect.getmodule | Up: inspect | Next: inspect.getmro
Rel: inspect.ArgInfo, inspect.Arguments, inspect.Attribute, inspect.BlockFinder
Ref: docs.python.org — inspect.getmodulename
Tags: #public #python3 #stdlib #inspect


Import

import inspect
from inspect import getmodulename

Signature & Overview

inspect.getmodulename(path)

Return the module name for a given file, or None.

Usage

import inspect

assert inspect.getmodulename("/path/to/helper.py") == "helper"
assert inspect.getmodulename("/path/to/readme.txt") is None

Gotchas

REPL Inspect

from inspect import getmodulename
help(getmodulename)

Linked from

Related notes