您的位置:首页 > 编程语言 > Python开发

python tutorial 学习笔记(三)

2011-04-01 18:14 393 查看
module –> .py file

import module_name

from module_name import *

module_name.__name__ #returns the module name

module can contain executable statments. They are executed only the first time the module is imported somewhere.

__name__ is “__main__” when the file is executed as main file. Thus statments after “if __name__ == “__main__:” are executed only when the file is main file.

Standard Modules

Python Libraray Reference.

sys module: sys.ps1, sys.path

__builtin__ module: just a name, already built-in

built-in function dir(): which names a module defines

Module Search Path

current directory( the main file directory)

PYTHONPATH(sys.path)

installation-dpendent default

Package:

must contain __init__.py file, it can define a list named __all__, containing all module names that should be imported when use “from package import *”

import p1.p2.module

from package import item, item can be a submodule or a function, calss or variable defined in the package
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: