python code debug

  1. python pdb debug
    we have sample code read_redis.py:
    import json
    import redis
    client = redis.Redis()
    data = client.lpop(‘info’)
    run it with command: python -i read_redis.py.
    once you got "exception occurred", start pdb debuggin as below:
>>> import pdb
>>> pdb.pm()
> c:\python\lib\site-packages\redis\connection.py(563)connect()
-> raise ConnectionError(self._error_message(e))
(Pdb) data
*** NameError: name 'data' is not defined
  1. VS CODE debug
    you can press F5 to start debugging python in VS CODE as below:

Leave a Reply

Your email address will not be published. Required fields are marked *