emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

documenting python module examples in orgmode


From: Divan Santana
Subject: documenting python module examples in orgmode
Date: Mon, 09 Dec 2019 12:38:58 +0200

Hi All,

I'm trying to document python module examples in orgmode.

I'm sure this is possible, but not quite sure how to do it.

I'd like to define the python module in one block, and then import it in
another.

#+NAME: my_module.py
#+begin_src python
print('Importing my_module...')

test = 'Test String'

def find_index(to_search, target):
    '''Find the index of a value in a sequence'''
    for i, value in enumerate(to_search):
        if value == target:
            return i

    return -1
#+end_src

#+NAME: intro.py
#+begin_src python
import my_module

courses = [ 'History', 'Math', 'Geography', 'Science' ]
#+end_src

How can one do this?

Thanks very much.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]