 (defun ds/pick-import-location ()
   (save-excursion
     (goto-char (point-min))
-    (re-search-forward "import\\|defun\\|class")
+    (re-search-forward "^def\\|^class" nil 'noerror)
+    (re-search-backward "^import\\|^from" nil 'noerror)
     (beginning-of-line)
     (point)))
 

(defun ds/python-importable-symbols (path)
  (when (f-exists-p path)
    (with-temp-buffer
      (shell-command (concat "sed -n -e 's/^def \\([a-zA-Z][a-zA-Z0-9_]*\\).*/\\1/p' -e 's/^class \\([a-zA-Z][a-zA-Z0-9_]*\\).*/\\1/p' " path) t "*python-importable-symbols-errors*")
      (--> (buffer-substring (point-min) (point-max))
           (s-split "\n" it)))))


         (default-symbol (when (symbol-at-point) (symbol-name (symbol-at-point))))
         (file (completing-read "import file: " files))
         (file-symbols (ds/python-importable-symbols (f-join (projectile-project-root) file)))
         (individual-symbol (completing-read "symbol(s): " file-symbols nil nil default-symbol))
         (import-statement-line (ds/path-to-import-statement file individual-symbol)))
    (if insert-here
        (insert import-statement-line)
