how to find available classes in a file ?

Alex Popescu the.mindstorm.mailinglist at gmail.com
Mon Jul 16 19:13:19 EDT 2007


On Jul 17, 1:44 am, Stef Mientki <S.Mientki-nos... at mailbox.kun.nl>
wrote:
> I want to have a (dynamically) list of all classes defined in a py-file.
> Is there a way of getting this list, without manually parsing the file ?
>
> thanks,
> Stef Mientki

I have written something that does something like this, but I am not
sure it is the pythonic way.
Bascially I am loading the module and then using dir() on the module
object I am looking for
attribute of the type classobj (for old style classes) and type type
(for new style classes).

I also heard of the inspect module, but I haven't checked it yet.

bests,
./alex
--
.w( the_mindstorm )p.





More information about the Python-list mailing list