Issue
For a presentation I want to show internal code inside packages in Jupyter notebook, I could manage to get the code, but it's plain text (image[1]), Is it exist a way to color the output like image[2]?
here's my code:
import inspect
def printSource(obj):
print(''.join(str(x) for x in inspect.getsourcelines(obj)[0]))
printSource(printSource)
I guess should be there a way, because when there's an error, shows colors like image[3]
Solution
You coud use %psource, but also you need to tell jupyter where to print, try this
from IPython.core import page
page.page = print
then, one per cell the function you want to show
%psource printSource
Answered By - Ivan C
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.