Package: debugp
debugprintA light weighted module aimed to help debug experienceInstallpip install debugpUsageUsedp()to show the expression value and keep  evaluate.importnumpyasnpfromdebugprintimportdpdp(np.dot(np.array([1,2,3]),np.array([[1],[2],[3]]),))[21:37:28] Debug info of line 11 in <module>:                  debugprint.py:50
        np.dot(np.array([1, 2, 3]), np.array([[1], [2], [3]])): [14]dp()support printing multiple expressions at the same time, and returns the result in a tuplefromdebugprintimportdpas_dpdefprint_arguments(*args):print(args)print_arguments(*_dp(1+2*3,[xforxinrange(10)ifx%3==0]))[08:34:17] Debug info of line 9 in <module>:                      debugprint.py:50                                                                                                                                                         debugprint.py:50
        1 + 2 * 3: 7
        [x for x in range(10) if x % 3 == 0]: [0, 3, 6, 9]
(7, [0, 3, 6, 9])You can usedp()multiple times in a linefromdebugprintimportdpas_dpa=2_dp(_dp(1+2*3)>>_dp(a))[08:49:04] Debug info of line 5 in <module>:                                                                                                                                                                              debugprint.py:27
        1 + 2 * 3: 7
        a: 2
        _dp(1 + 2 * 3) >> _dp(a): 1ConfigurationStyleYou can change the default color withdp_conffromdebugprintimport*dp_conf.pseudo="yellow"a=2dp(dp(1+2*3)>>dp(a))Before:After:Enable / DisableYou can enable or disable debug print by manipulatingdp_conf.enabledfromdebugprintimport*a=1dp_conf.enabled=Falsedp(dp(1+2*3)>>dp(a))# Won't print a thing!Print HookYou can use a custom function to convert object to string!fromdebugprintimport*fromobjprintimportobjstrclassA:def__init__(self,foo,bar):self.foo=fooself.bar=barself.baz=B()classB:def__init__(self):self.x=1self.y=2obj=A("foo","bar")dp(obj)# information from repr(obj) is not helpfuldp_conf.print_hook=objstr# change the hook from repr to objstrdp(obj)[09:50:25] Debug info of line 17 in <module>:                                                                                                                                                                             debugprint.py:27
        obj: <__main__.A object at 0x000001985793E950>
        
           Debug info of line 20 in <module>:                                                                                                                                                                             debugprint.py:27
        obj: <A 0x1985793e950
                  .bar = 'bar',
                  .baz = <B 0x1985793e8f0
                    .x = 1,
                    .y = 2
                  >,
                  .foo = 'foo'
                >You can find more detail indebugprint/config.pyKnown BugsCannot usedp()in the python interactive consoledp()does not work whenmultiple statements in one line, i.e.dp(1); dp(2)Three layers of nesteddp()in different lines produces unexpected context hintdp(dp((1,(dp(2))))+(2,))[13:45:35] Debug info of line 9 in <module>:                                                                                                                                                                              debugprint.py:28
        2: 2

           Debug info of line 7 in <module>:                                                                                                                                                                              debugprint.py:28
        (1, dp(2)): (1, 2)

           Debug info of line 6 in <module>:                                                                                                                                                                              debugprint.py:28
        (1, dp(2)): (1, 2, 2) # uh-oh