Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

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

Examples

> py-module-name module_name/resolve.py
module_name.resolve

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

> py-module-name -f /tmp/not_package/standalone.py
'/tmp/not_package/standalone.py'

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

.vimrc

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>
Release History

Release History

This version
History Node

0.5.1

History Node

0.5

History Node

0.4

History Node

0.3

History Node

0.2

History Node

0.1

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
module_name-0.5.1.tar.gz (3.1 kB) Copy SHA256 Checksum SHA256 Source Aug 19, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting