Hello. From a Python file I want to extract the imported library names. For example:

import sublime, sublime_plugin as sp
from os import path as eric
import os, datetime, tempfile, desktop    # some comment
I want to collect sublime, sublime_plugin etc.. I might also want to collect the (as) aliases, but initially I'm just interested in the library names.

I can assume that from or import are at the beginning of the lines, and they may be followed by eol, whitespace or # (indicating a comment).

This may be straight-forward