python-shell-buffer-substring

python-shell-buffer-substring is a compiled Lisp function in `python.el'.

(python-shell-buffer-substring START END &optional NOMAIN)

Send buffer substring from START to END formatted for shell.
This is a wrapper over `buffer-substring' that takes care of
different transformations for the code sent to be evaluated in
the python shell:
1. When optional argument NOMAIN is non-nil everything under an
"if __name__ == '__main__'" block will be removed.
2. When a subregion of the buffer is sent, it takes care of
appending extra empty lines so tracebacks are correct.
3. When the region sent is a substring of the current buffer, a
coding cookie is added.
4. Wraps indented regions under an "if True:" block so the
interpreter evaluates them correctly.