推荐学习书目
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 · 3018 views
    This topic created in 1961 days ago, the information mentioned may be changed or developed.

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

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

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

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