How to watch for a variable change in python without dunder setattr or pdb

前端 未结 5 730
南方客
南方客 2020-12-05 05:44

There is large python project where one attribute of one class just have wrong value in some place.

It should be sqlalchemy.orm.attributes.InstrumentedAttribute, but

5条回答
  •  北荒
    北荒 (楼主)
    2020-12-05 06:28

    You can use the python debugger module (part of the standard library)

    To use, just import pdb at the top of your source file:

    import pdb
    

    and then set a trace wherever you want to start inspecting the code:

    pdb.set_trace()
    

    You can then step through the code with n, and investigate the current state by running python commands.

提交回复
热议问题