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

你们的__init__.py 都用来干啥呢

  •  
  •   ivito ·
    fireboyvt · Dec 15, 2015 · 4750 views
    This topic created in 4002 days ago, the information mentioned may be changed or developed.
    不同的代码中__init__.py 用法千差万别。
    有的人什么都不写,只为了告诉解释器这个文件夹是个 package
    有的人写一些变量的定义
    有的人把核心逻辑各种 class 定义都摆到这里

    那么问题来了,在日常的工作学习中你都用__init__.py 干点啥呢,符合规范吗?
    9 replies  •  2015-12-15 18:28:25 +08:00
    vanxining
    vanxining
    Dec 15, 2015 via Android
    1
    更改、补充原生模块的接口。
    Damnever
    Damnever
    Dec 15, 2015
    2
    http://docs.python-guide.org/en/latest/writing/structure/#packages 里面说最好不要写太多代码。。。

    像楼上说的,有时候也写点代码。。。 https://github.com/Damnever/Chat-Room/blob/master/handlers/__init__.py
    elvis_w
    elvis_w
    Dec 15, 2015
    3
    既然是 init ,那就写这个 package 初始化的代码啊
    pynix
    pynix
    Dec 15, 2015
    4
    一半是写 API 。。。
    gkiwi
    gkiwi
    Dec 15, 2015
    5
    用来写 API
    fy
    fy
    Dec 15, 2015
    6
    破事水呀,这东西没标准吧
    broven
    broven
    Dec 15, 2015
    7
    写个作者,哈哈
    Feiox
    Feiox
    Dec 15, 2015
    8
    写个版本,嘿嘿
    wenbinwu
    wenbinwu
    Dec 15, 2015
    9
    __all__
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1934 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 09:11 · PVG 17:11 · LAX 01:11 · JFK 04:11
    ♥ Do have faith in what you're doing.