Home Download Buy Blog Forum Support

Extract names of imports

Extract names of imports

Postby agibsonsw on Mon Apr 30, 2012 3:22 pm

Hello. I want to use the ST-API find_all() call to extract the names of imported libraries from a Python file in the view.

Code: Select all
import wibble
import weeble as wee
from nee import shrubbery, water_effect
from knights import lancelot as brave, arthur as king

I want to extract the library names, not their aliases (as).

I was planning to wrestle with the regex, but I'm assuming someone has already done this before :)

I should also check that it is not commented out - either at the beginning of the line, or somewhere in the middle.

Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Return to Technical Support

Who is online

Users browsing this forum: Exabot [Bot] and 16 guests