[Python-ideas] PEP x: Static module/package inspection

Nick Coghlan ncoghlan at gmail.com
Thu Feb 2 14:35:10 CET 2012

On Thu, Dec 29, 2011 at 1:28 AM, Michael Foord <fuzzyman at gmail.com> wrote:
> On a simple level, all of this is already "obtainable" by using the ast
> module that can parse Python code. I would love to see a "python-object"
> layer on top of this that will take an ast for a module (or other object)
> and return something that represents the same object as the ast.
> So all module level objects will have corresponding objects - where they are
> Python objects (builtin-literals) then they will represented exactly. For
> classes and functions you'll get an object back that has the same attributes
> plus some metadata (e.g. for functions /  methods what arguments they take
> etc).
> That is certainly doable and would make introspecting-without-executing a
> lot simpler.

The existing 'clbr' (class browser) module in the stdlib also attempts
to play in this same space. I wouldn't say it does it particularly
*well* (since it's easy to confuse with valid Python constructs), but
it tries.


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-ideas mailing list