Mar-24-2022, 05:34 PM
i'm not sure how to look for this. i would like a tool that can be given a file (or stdin) with code and the name of a function or class or method which will extract that function or class or method and output it.
inspect.getsource()
?(Mar-25-2022, 07:06 AM)Gribouillis Wrote: [ -> ]Are you looking for inspect.getsource() ?almost. if the code i want to extract from can be imported as a module, this could work. for stdin i'd have to copy it to a file, first, unless there is a way to import from stdin or a list of str or a big str.
(Mar-25-2022, 06:27 AM)ndc85430 Wrote: [ -> ]For what purpose?to extract source code of a function or class to the end of that function or class, comiing from a file or stdin. this is to find the end of that function or class. maybe parsing indentation (after disposing of comments) would be the easy way.
(Mar-25-2022, 06:38 PM)ndc85430 Wrote: [ -> ]If that's not what you mean, please clarify.
(Mar-25-2022, 06:38 PM)ndc85430 Wrote: [ -> ]Also, what kind of editor/IDE are you using?emacs/bash within a nearly full screen xterm (i use the same for C and everything else).
(Mar-25-2022, 06:38 PM)ndc85430 Wrote: [ -> ]Still, I strongly suggest refactoring these large things.refactoring each function/class makes more sense once they are isolated from each other.