Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

Import for Humans 💅🏻

Project description

This is to be a project on modifying sys.metapath and making Python import statement as smooth as possible.


This idea was originally inspired from the Bro/Zeek language, where it uses @load statement what import doses in Python, except that the @load statement takes a relative path as its specifier. For example:

@load ./sample_local.bro
@load ../sample_parent.bro
@load ../sample/child.bro

with the project structure as following:

|-- foo
|   |-- this_script.bro
|   |-- sample_local.bro
|   |-- sample
|       |-- child.bro
|-- sample_parent.bro

which means, the @load statement is always relative to where it comes from, rather than a working directory or package root as in Python.

Thus, we intend to make the Python import statement works just like @load. This is the back story of the impfxxk project.


When your project is as such:

|-- foo
|   |--
|   |--
|   |-- sample
|       |--

Normally, you will want to do:

import .sample_local
import .sample.child
import ..sample_parent

there can be some issues when the Python interpreter tries to figure out what is what when you are not running it at /root/foo/, where the relative paths are ought to be.

However, with impfxxk, you can simply add a statement (it’s not decided yet) before your original import statements, just like __future__ does; and your code will work just as you wish.

Project details

Download files

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

Files for impfxxk, version 0.0.0.dev0
Filename, size File type Python version Upload date Hashes
Filename, size impfxxk-0.0.0.dev0-py3-none-any.whl (3.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size impfxxk-0.0.0.dev0.tar.gz (3.3 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page