Skip to main content

Simple Module to resolve module namespace

Project description

Simple module to make it easy to run python files with -m flag.

The benefits of running with -m is that your relative imports will work. Running a python file as a script doesn’t understand that it is part of a package.

usage: py-module-name [-h] [-f] [-d] path

positional arguments:
  path         path to python file

optional arguments:
  -h, --help   show this help message and exit
  -f, --flag   Will output -m flag if path is importable
  -d, --debug  Debug


> py-module-name module_name/

> py-module-name -f module_name/
-m 'module_name.resolve'

> py-module-name -f /tmp/not_package/

The -f flag is useful for use with scripting. I use it from my .vimrc to run files I am editing.


autocmd FileType python map <buffer> <S-r> :w<CR>:!tmux send-keys -t :.{bottom-right} "\%time \%run `py-module-name -f %:p`" enter<CR><CR>

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
module_name-0.5.1.tar.gz (3.1 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page