V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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
liuchang0812
V2EX  ›  Python

分享自己写的文章:介绍关于 python import 的常见问题、实现与拓展

  •  
  •   liuchang0812 · 2015-10-25 20:15:39 +08:00 · 2988 次点击
    这是一个创建于 3098 天前的主题,其中的信息可能已经有所发展或是发生改变。

    文章包含下面的内容:

    • python 引入机制

      1. 相对引入
      2. 完全引入
    • 一些实践经验

      1. 打包
      2. virtualenv
      3. 引入方式的选择
    • python import 的实现

      1. finder
      2. loader
      3. importer
      4. meta_path
      5. path_hook
    • python hook

      1. hook 实现方法
      2. hook 例子

    文章地址: https://github.com/Liuchang0812/slides/tree/master/pycon2015cn
    头条地址: http://toutiao.io/posts/um73rm

    8 条回复    2015-10-26 21:57:28 +08:00
    freeandeasy
        1
    freeandeasy  
       2015-10-25 20:21:33 +08:00
    话说我昨天还是前天查 import 规范的时候貌似看到这篇文章了。
    jimmy66
        2
    jimmy66  
       2015-10-25 20:28:21 +08:00
    已 star ,收藏慢慢看
    mywaiting
        3
    mywaiting  
       2015-10-25 21:28:48 +08:00
    python import 的常见问题中竟然没有写循环 import 的问题,略差评啊
    lll9p
        4
    lll9p  
       2015-10-25 21:34:43 +08:00   ❤️ 1
    在之后的版本和 Python3 版本, *相对* 引用已经成为默认的引用方式。?
    liuchang0812
        5
    liuchang0812  
    OP
       2015-10-25 22:27:44 +08:00
    @lll9p 谢谢,已经修正
    liuchang0812
        6
    liuchang0812  
    OP
       2015-10-25 22:30:02 +08:00
    @mywaiting 对循环引用不是特别的清晰,平时自己碰到较少,就没有写。欢迎 PR ,帮着补全。
    adrianzhang
        7
    adrianzhang  
       2015-10-25 23:10:28 +08:00
    很用心的文章。
    Damnever
        8
    Damnever  
       2015-10-26 21:57:28 +08:00
    @liuchang0812

    关于循环引用,这个老社区里面还有些好东西 http://wiki.woodpecker.org.cn/moin/MiscItems/2008-11-25
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3198 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 13:23 · PVG 21:23 · LAX 06:23 · JFK 09:23
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.