cool-RR / PySnooper

Never use print for debugging again
MIT License
16.37k stars 951 forks source link

print value of a claas var #227

Closed smjaberl closed 2 years ago

smjaberl commented 2 years ago

Hi,

just have a look on this simple code example:

import pysnooper

class test: @pysnooper.snoop() def init(self): a=10 self.b = 12 / 3 c = a / 2 a = c

test()

the output of pysnooper is this

Source path:... /workspaces/pysnooper-test.py Starting var:.. self = <main.test object at 0x7f5b75c6ab60> 23:39:15.038150 call 5 def init(self): 23:39:15.038330 line 6 a=10 New var:....... a = 10 23:39:15.038350 line 7 self.b = 12 / 3 23:39:15.038387 line 8 c = a / 2 New var:....... c = 5.0 23:39:15.038405 line 9 a = c Modified var:.. a = 5.0 23:39:15.038428 return 9 a = c Return value:.. None

I think it would be very nice, if I could see the value of self.b as well as the value of a, c, and d.

cool-RR commented 2 years ago

pysnooper.snoop(watch=('self.b',))