initialising a class by name

Sion Arrowsmith siona at chiark.greenend.org.uk
Wed Jan 14 08:55:38 EST 2009


Krishnakant  <krmane at gmail.com> wrote:
>By the way, is there a kind of global list of modules/classes which are
>maintained in a package once the program is loaded into memory?

sys.modules is a dict of loaded module objects, keyed by module name.
So:

>>> getattr(sys.modules["sys"], "version_info")
(2, 5, 0, 'final', 0)

-- 
\S -- siona at chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
   "Frankly I have no feelings towards penguins one way or the other"
        -- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump



More information about the Python-list mailing list