w (memq (following-char) '(?r ?R))
                   start (match-end 0))
             (goto-char start)
             (while (not (memq (following-char) '(0 ?\")))
               (skip-chars-forward "^\"\\\\")
               (if (= (following-char) ?\\) (forward-char 2)))
             (if (eobp)
                 (setq contents nil
                       start nil)
               (setq end (point))
               (forward-char 1))
             (setq resume (point)))
            ((looking-at "[rR]?'")      ; single-quoted string
             (setq raw (memq (following-char) '(?r ?R))
                   start (match-end 0))
             (goto-char start)
             (while (not (memq (following-char) '(0 ?\')))
               (skip-chars-forward "^'\\\\")
               (if (= (following-char) ?\\) (forward-char 2)))
             (if (eobp)
                 (setq contents nil
                       start nil)
               (setq end (point))
               (forward-char 1))
             (setq resume (point)))
            (t                          ; no string anymore
             (setq start nil
                   continue nil)))
      (if start
          (setq contents (concat contents
                                 (if raw
                                     (buffer-substring start end)
                                   (po-extract-part-unquoted (current-buffer)
                                                             start end))))))
    (goto-char resume)
    contents))

(defun po-mark-python-string (start end keyword)
  "Mark the Python string, from START to END, with KEYWORD.
If KEYWORD is '.', prefix the string with an empty string of the other type.
Leave point after marked string."
  (cond ((string-equal keyword ".")
         (goto-char end)
         (save-excursion
           (goto-char start)
           (insert (cond ((= (following-char) ?\') "\"\"")
                         ((= (following-char) ?\") "''")
                         (t "??")))))
        (t (goto-char end)
           (insert ")")
           (save-excursion
             (goto-char start)
             (insert keyword "(")))))
