On Thu, Dec 29, 2011 at 1:28 AM, Michael Foord <fuzzyman@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. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia