Skip to main content
Join the official Python Developers Survey 2018 and win valuable prizes: Start the survey!

Import modules written in org files

Project description

#+TITLE: orgmod

[[https://img.shields.io/pypi/v/ledge.svg?style=flat-square]]

Write literate python modules in org mode and import directly in python.
Inspired by [[https://github.com/miedzinski/import-pypi][import-pypi]]. Relies on org-babel and tangling facility.

As an example, lets make this README an importable module. Lets define a
~hello_world~ function.

#+BEGIN_SRC python :tangle yes
def hello_world():
print("hello world")
#+END_SRC

In the header for the above code snippet, we set ~:tangle yes~ (checkout the raw
version of this file). This creates a module with the name ~README~.

Now to import this module we first import ~orgmod~ and then import ~README~ and then
run the next code right inside this file.

#+BEGIN_SRC python :results output :exports both
# For this code block, tangle is not set
import orgmod
import README

README.hello_world()
#+END_SRC

#+RESULTS:
: hello world

-----

*Things to do*

- Make the loader and finder more robust and inherit from the newer abstract
classes.
- Move next iterations of orgmod itself inside this README. Might need to
bootstrap from the simpler script thats present right now.

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
orgmod-0.1.1.tar.gz (14.8 kB) Copy SHA256 hash SHA256 Source None Apr 2, 2018

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