Python中__init__.py如何使用?,python__init__.py,2015/8/26 一
Python中__init__.py如何使用?,python__init__.py,2015/8/26 一
2015/8/26
一直以来对__init__.py在Python中的作用比较模糊,一致认为它大概的作用是: 让一个目录(directory)编程一个包(package),google之后的答案是:
The __init__.py files are required to make Python treat the directories as containing packages; this is done to prevent directories with a common name, such as string, from unintentionally hiding valid modules that occur later on the module search path. In the simplest case, __init__.py can just be an empty file, but it can also execute initialization code for the package or set the __all__ variable, described later.
==>http://stackoverflow.com/questions/448271/what-is-init-py-for
==>https://docs.python.org/2/tutorial/modules.html#packages
大家一般是是如何使用的(在该文件中写些什么)?
编橙之家文章,
相关内容
- django 如何根据时间统计数据库中的数据?,django数据库
- Sublime如何切换补全的候选项?,sublime切换补全,sublim
- 大家用doctest时中文有问题吗?怎么解决的,doctest中文
- Bluepoint 实现二级域名,bluepoint二级域名,flask 中bluep
- Python list内容的改变问题,pythonlist,Pyhton 新手。今天
- rails入门时的NoMethodError in Articles#show,,刚刚入门rails,
- Mac下无法用PyCharm建立默认文件结构的Flask项目,,使用
- python selenium,当前窗口跳转在返回原页面,cache被清空
- 如何计算elastic search查询中的纪录条数,elasticsearch,fr
- python模拟登录成功,但是抓取网页还是没有登录的,什
评论关闭