the inspect thing

C

castironpi

-----the code:
class A:
b=2

import inspect
print inspect.getsource(A)

class A:
c=2
print inspect.getsource(A)

-----unavailable from the console, but gets you:
class A:
b=2

class A:
b=2

One thought is, in inspect, could at least:
def findsource(object):
#snip
if candidates:
# this will sort by whitespace, and by line number,
# less whitespace first
candidates.sort()
return lines, candidates[0][1]
be
return lines, candidates[-1][1]
to get the most recent?

Why no cl_firstlineno in the object for the class, or access to the
code?-acb
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top