468,284 Members | 1,625 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,284 developers. It's quick & easy.

the inspect thing

-----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

May 10 '07 #1
0 843

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Hans Georg Krauthaeuser | last post: by
2 posts views Thread by Fernando Perez | last post: by
11 posts views Thread by It's me | last post: by
reply views Thread by Ron Adam | last post: by
4 posts views Thread by Wal Turner | last post: by
1 post views Thread by aj | last post: by
4 posts views Thread by Chris Pax | last post: by
8 posts views Thread by Aaron \Castironpi\ Brady | last post: by
reply views Thread by rajasankar | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.