[Python-ideas] parser in stdlib

Aaron Brady castironpi at comcast.net
Sun May 13 22:27:59 CEST 2007


> -----Original Message-----
> From: python-ideas-bounces+castironpi=comcast.net at python.org
> [mailto:python-ideas-bounces+castironpi=comcast.net at python.org] On Behalf
> Of Aaron Brady
> 
> > -----Original Message-----
> > From: python-ideas-bounces at python.org [mailto:python-ideas-
> > bounces at python.org] On Behalf Of Terry Reedy
> > [snip]
> 
> I've very much looked into it.  In fact, it gave rise to the follow-up
> idea
> of attaching a `firstlineno' attribute to class objects.  (18:12 American
> Central Time.)  Rather costly, 50% of the attributes, but stepping through
> the InteractiveCodeGenerator class hasn't failed yet.

This is better.  Inspect.getsource( AClass ) can be wrong.  Raise exceptions
before that happens.

import inspect
class A:
	b=1

class A:
	b=2

B=A
print inspect.getsource(B)

Output is:

class A:
        b=1

Which is not what I asked it.  Return candidates maybe?





More information about the Python-ideas mailing list