Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added python code for psource (#613)
  • Loading branch information
VishnuDuttSharma committed Aug 11, 2017
commit d2e32ec74c37e8e265e3d0c2da55d651e649b9a3
14 changes: 14 additions & 0 deletions notebook.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
from IPython.display import HTML, display

from inspect import getsource
from pygments.formatters import HtmlFormatter
from pygments.lexers import PythonLexer
from pygments import highlight

from utils import argmax, argmin
from games import TicTacToe, alphabeta_player, random_player, Fig52Extended, infinity
from logic import parse_definite_clause, standardize_variables, unify, subst
Expand All @@ -15,6 +21,14 @@
# ______________________________________________________________________________


def psource(*functions):
"Print the source code for the given function(s)."
display(HTML(highlight(''.join(getsource(fn) for fn in functions), PythonLexer(), HtmlFormatter(full=True))))


# ______________________________________________________________________________


def show_iris(i=0, j=1, k=2):
'''Plots the iris dataset in a 3D plot.
The three axes are given by i, j and k,
Expand Down