Right, I hadn't thought about empty lines in any kind of statement. I guess I got too excited after learning a little bit of lisp, and thinking the function was so beautiful. I'll think about making it more robust. Thanks for the response!

On Sun, 30 Jul 2023, 08:29 Eshel Yaron, <me@eshelyaron.com> wrote:
Hi there,

>> Dear python-mode maintainers,

I'm not a `python-mode` maintainer, just a user, but here are my two cents:

>> I'd like to suggest adding the following command to python.el,
>> and binding it to C-<return> by default. I'd love to hear your
>> thoughts.

Regardless of the command, I'd consider picking another binding
(perhaps along side this one) since some users (including yours truly)
are used to press `C-m` instead of the `<return>` key.

>> (defun python-shell-send-paragraph (&optional send-main msg)
>>   "Send all lines of code between two white lines to inferior
>> Python process. SEND-MAIN defaults to nil and MSG to t.
>> See `python-shell-send-region for more information.

I'd say something like "SEND-MAIN and MSG have the same meaning as in
`python-shell-send-paragraph', which see." to make this more obvious.

>> Interactively, SEND-MAIN is the prefix argument"
>>   (interactive "Pi")

This is probably supposed to be `(interactive "P\ni")`?

>>   (python-shell-send-region
>>    (or (save-excursion (re-search-backward "^[:blank:]*$" nil t)) (point-min))
>>    (or (save-excursion (re-search-forward  "^[:blank:]*$" nil t)) (point-max))

This method of finding the boundaries of the paragraph at point seems
slightly ad-hoc and fragile, I wonder what happens if there's a blank
line in the middle of a multi-line string?

>>    send-main (not msg) t))

Just a couple of thoughts :)

Best,

--
Eshel