Which Python IDE can run my script line-by-line?

后端 未结 15 818
小鲜肉
小鲜肉 2021-02-01 02:38

I wouldn\'t call myself programmer, but I\'ve started learning Python recently and really enjoy it.

I mainly use it for small tasks so far - scripting, text processing,

15条回答
  •  花落未央
    2021-02-01 03:08

    I would plump for EMACS all round.

    If you're looking for a function to run code line by line (or a region if you have one highlighted), try adding this to your .emacs (I'm using python.el and Pymacs):

    ;; send current line to *Python
    (defun my-python-send-region (&optional beg end)
    (interactive)
    (let ((beg (cond (beg beg)
                   ((region-active-p)
                    (region-beginning))
                   (t (line-beginning-position))))
        (end (cond (end end)
                   ((region-active-p)
                    (copy-marker (region-end)))
                   (t (line-end-position)))))
    (python-shell-send-region beg end)))
    
    (add-hook 'python-mode-hook
          '(lambda()
             (local-set-key [(shift return)] 'my-python-send-region)))
    

    I've bound it to [shift-Return]. This is borrowed from here. There's a similar keybinding for running .R files line by line here. I find both handy.

提交回复
热议问题