推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
chaleaoch
V2EX  ›  Python

pycharm 或者其他 ide 或者 pdb 有没有根据条件自动断点的功能

  •  
  •   chaleaoch · Jan 24, 2021 · 3421 views
    This topic created in 2123 days ago, the information mentioned may be changed or developed.

    就是说, pdb 监控程序,当满足某个条件(譬如某个变量 == 某个值), 程序暂停.

    我现在不知道某个变量是在哪里被赋的值. 如果有这个功能就很容易了,要不然只能单步, 慢慢看.

    13 replies  •  2021-01-25 14:12:56 +08:00
    jhdsgfww
    jhdsgfww
    Jan 24, 2021
    1
    用 ipdb 直接写在代码里面试一下?
    ```python
    import ipdb

    # some codes here.
    if somevar == somevalue:
    ipdb.set_trace()
    # some codes here.
    ```
    labubu
    labubu
    Jan 24, 2021
    2
    pycharm 不是有吗?
    j0hnj
    j0hnj
    Jan 24, 2021 via iPhone
    3
    pycharm 在断点上右键可以设置
    UN2758
    UN2758
    Jan 24, 2021
    4
    有啊,
    UN2758
    UN2758
    Jan 24, 2021❤️1
    5
    xiaolinjia
    xiaolinjia
    Jan 24, 2021
    6
    或许你可以试试,pysnooper 这个库。
    cabing
    cabing
    Jan 24, 2021
    7
    改用微软的 vscode,一级棒。
    milkpuff
    milkpuff
    Jan 24, 2021
    8
    python 代码里面可以直接调用 breakpoint()函数
    tiedan
    tiedan
    Jan 25, 2021
    9
    在断点直接右键可以添加触发条件
    reed2020
    reed2020
    Jan 25, 2021
    10
    右击 PyCharm 的断点红点就有
    wbyyffhh
    wbyyffhh
    Jan 25, 2021
    11
    学到了
    no1xsyzy
    no1xsyzy
    Jan 25, 2021❤️1
    12
    修改断点设置有点不对吧,连在哪赋值的都不知道……
    1. (不管哪个) IDE 能够自动选中所有变量引用( PyCharm 默认 Alt+F7 )
    2. Pysnooper ? Cyberbrain ?
    3. 如果是属性值,可以迅速转写成一个 property 并在 setter 里加断点。
    4. 二分法 trace 。
    chaleaoch
    chaleaoch
    OP
    Jan 25, 2021
    13
    @no1xsyzy 感谢感谢. 是我想要的.
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   956 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 21:14 · PVG 05:14 · LAX 13:14 · JFK 16:14
    ♥ Do have faith in what you're doing.