|
Prev
| Next
|
|
|
|
|
|
|
Example Inclusion of Source Code
Inline Source Code
Contents of src_example.py
Escape Character
Just Usage Message
Contents
Inline Source Code
The following is an example of in-line source code
extern std::set< std::string > string_set(const char* c_string);
Contents of src_example.py
Note that a newline is automatically added at the beginning
of a file:
#! /usr/bin/python3
# $begin src_example.py$$ $newlinech #$$ $escape $$
# $spell srcthisfile src py$$
# $section Example Python Source File$$
# $head Usage$$
# $srcthisfile%0%# BEGIN USAGE%# END USAGE%2%$$
# $head Discussion$$
# Note the $code srcthisfile$$ command skips the first two
# $code # BEGIN USAGE$$ in $code src_example.py$$.
# $end
import sys
# BEGIN USAGE
usage = 'src_example.py value'
# END USAGE
if len(sys.argv) != 2 :
sys.exit(usage)
value = float( sys.argv[1] )
square = value * value
output = 'value * value = ' + str(square)
print(output)
Escape Character
Change the escape character from #
to !
so #
can be used normally as part of the start
and stop sequences:
Just Usage Message
Note that the newline following
# BEGIN USAGE
is included:
%
Contents
Input File: omh/getstarted/src_example.omh