-
-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a utility function for getting filename info from code objects #29
Labels
Milestone
Comments
Maybe something like def finfo(codeobj): """Returns the file and line number of a code object. If the code object has a __file__ attribute (e.g. if it is a module), then the returned line number will be 0 """ fname = getattr(codeobj, '__file__', None) linenum = 0 if fname is None: func_code = codeobj.__code__ fname = func_code.co_filename linenum = func_code.co_firstlineno fname = fname.replace('.pyc', '.py') return fname, linenum |
Yep, looks good! |
I'll add it. I think I'll add a couple of things for anti8 as well. Thanks, |
Thanks! Can you also add documentation for the new function? |
I'll try to figure that out :) |
Closed
Done in the code cleanup. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think it would be useful to have https://github.com/berkerpeksag/astor/blob/master/astor/misc.py#L185-190 as an helper in astor.
The text was updated successfully, but these errors were encountered: