推荐学习书目
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
redhatping
V2EX  ›  Python

如何阅读理解 python 第三方库 ?

  •  
  •   redhatping · Aug 26, 2016 · 3467 views
    This topic created in 3591 days ago, the information mentioned may be changed or developed.
    如查看 BeautifulSoup 的源代码, 几个文件, 看不懂纠缠在一起啊。 有什么思路去理解库的源代码呢?
    10 replies    2016-08-27 23:34:43 +08:00
    knightdf
        1
    knightdf  
       Aug 26, 2016
    从你怎么使用的顺着去看,你看看 scrapy 之类的源码相信你更蛋疼
    zhuangzhuang1988
        2
    zhuangzhuang1988  
       Aug 26, 2016
    写个 hello world
    然后下断点调试..
    julyclyde
        3
    julyclyde  
       Aug 26, 2016
    从运行时入口开始看
    lovepython
        4
    lovepython  
       Aug 26, 2016
    从你调用的入口开始往下追踪
    VicYu
        5
    VicYu  
       Aug 26, 2016
    Debug -> Next -> goto Next

    forever
    redhatping
        6
    redhatping  
    OP
       Aug 26, 2016 via iPhone
    @knightdf 这么疼
    hihihihihi
        7
    hihihihihi  
       Aug 26, 2016
    楼主可能编程经验还不够丰富, 所以才会又这样的困扰吧.

    就我自己来说, 如果我要看某个库的文件, 我通常会用 IDE 一次全部把源代码目录书都加载进来,
    通常根据目录 /文件名就能推测大致上是实线什么功能的, 在看代码之前, 我通常会先思考如果是我自己来写,
    我会如何去实线这些功能, 然后再去看代码, 基本大致看看方法名就能验证我的想法, 对于我没有考虑到的, 稍微多看一下, 研究下有没有我没想到的地方.

    大致上就是这样一个循序渐进的过程了.

    当你经验足够多的时候, 其实编程语言, 源代码都只是工具. 核心还是解决问题的思路和创意.
    Kisesy
        8
    Kisesy  
       Aug 26, 2016
    代码抄多了就不会有这问题了
    xi2008wang
        9
    xi2008wang  
       Aug 27, 2016
    从文档了解功能,从__int__.py 了解结构,从关键的 class 等入手
    huntzhan
        10
    huntzhan  
       Aug 27, 2016   ❤️ 1
    最好带着问题去阅读源码, 不要抱着"为了学习 xxx 去读 yyy 的源码"这种太过模糊的目标去学习. 建议你把问题分解, 比如"BeautifulSoup 是加载页面的?"这种问题, 然后去 GitHub 上搜代码, 把相关代码的规模缩小, 然后再进行阅读.

    如果读不懂, 大概是缺了某些前置技能.
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1112 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 60ms · UTC 18:08 · PVG 02:08 · LAX 11:08 · JFK 14:08
    ♥ Do have faith in what you're doing.