Tonsky: Don't go crazy with Clojure unless it makes you happy
1–5 of 5 posts
Re: Tonsky: Don't go crazy with Clojure unless it makes you happy
#2This is why I started to learn Common Lisp a year ago. This is the kind of power I miss when I have to go back to Python…
Re: Tonsky: Don't go crazy with Clojure unless it makes you happy
#3That's not the title of the article, nor a description of its content
Re: Tonsky: Don't go crazy with Clojure unless it makes you happy
#4This is why I started to learn Common Lisp a year ago. This is the kind of power I miss when I have to go back to Python…
I don't think there's anything in the post that you can't do in python. You can definitely get at the AST for a function using the inspect module, and similarly finding the file it's declared in and on which lines is entirely something you can get at from python.
Looking it up quickly it seems that inspect.getsourcelines[0] is just about perfect. Combining that with a slight misuse of inspect.cleandoc[1] and you've basically got the OP reproduced without even needing to resort to anything especially tricky.
[0] https://docs.python.org/3/library/inspect.html#inspect.getso... [1] https://docs.python.org/3/library/inspect.html#inspect.clean...
Re: Tonsky: Don't go crazy with Clojure unless it makes you happy
#5[dead]