I wrote this function which takes a string and writes out self.var for each entry in the string. This helps me create python classes faster.
(defun elf-python-self (str) "Parse the arguemnts in STR and write out self.var = var." (interactive (list (read-string "Argument List: "))) (message str) (let ((var-list (split-string str ",")) (var-name)) (forward-line) (move-beginning-of-line nil) (while (> (length var-list) 0) (setq var-name (strip (pop var-list))) (message var-name) (insert (format " self.%s = %s\n" var-name var-name)))))
If I type
a, b, c then I get the following
self.a = a self.b = b self.c = c
How do I modify this function to apply the code to the selected region?