emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Divan Santana <divan@santanas.co.za>
To: emacs-orgmode@gnu.org
Subject: documenting python module examples in orgmode
Date: Mon, 09 Dec 2019 12:38:58 +0200	[thread overview]
Message-ID: <87k175dbr1.fsf@santanas.co.za> (raw)

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	other threads:[~2019-12-09 10:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-09 10:38 Divan Santana [this message]
2019-12-09 14:19 ` John Kitchin
2019-12-09 14:25 ` Kaushal Modi
2019-12-11 12:44 ` Divan Santana

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k175dbr1.fsf@santanas.co.za \
    --to=divan@santanas.co.za \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).