emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* documenting python module examples in orgmode
@ 2019-12-09 10:38 Divan Santana
  2019-12-09 14:19 ` John Kitchin
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Divan Santana @ 2019-12-09 10:38 UTC (permalink / raw)
  To: emacs-orgmode

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-12-11 13:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-09 10:38 documenting python module examples in orgmode Divan Santana
2019-12-09 14:19 ` John Kitchin
2019-12-09 14:25 ` Kaushal Modi
2019-12-11 12:44 ` Divan Santana

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).