File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ def nb(body, args):
1313 p = args [0 ] if args else q [print ] # custom print function hook
1414 newbody = []
1515 with q as init :
16+ _ = None
1617 theprint = ast_literal [p ]
1718 newbody .append (init )
1819 for stmt in body :
Original file line number Diff line number Diff line change 44
55def test ():
66 with nb :
7+ assert _ is None
78 2 + 3 # top-level expressions autoprint, and auto-assign result to _
89 assert _ == 5 # ...and only expressions do that, so...
910 _ * 42 # ...here _ still has the value from the first line.
@@ -15,6 +16,7 @@ def test():
1516 print ("*** SymPy not installed, skipping symbolic math test ***" )
1617 else :
1718 with nb (pprint ): # you can specify a custom print function (first positional arg)
19+ assert _ is None
1820 x , y = symbols ("x, y" )
1921 x * y
2022 assert _ == x * y
You can’t perform that action at this time.
0 commit comments