Ⅰ.Object

  • Object表示内存实体,Variable仅仅是该内存实体的一个Reference,如下图所示:
a = 3

python object

  • 类型信息被封装在Object中而非Variable中,Object中存在type dessgnator字段;
  • Object的生命周期由Python的垃圾回收机制处理,Object中存在reference counter字段;
  • Object的类型分为mutable (e.g. list, dict, set etc.)和immutable (e.g. built-in types etc.);

Ⅱ. Module and Package

1. What is Module?

A Python program consisits of one main top-level file and zero or more modules.

A Python module is the highest-level program organization unit, which packages program code and data for reuse, and provides self-contained namespaces that minimize variable name clashes across your programs.


Python Module的优点

  • 模块化编程;
  • 管理命名空间(namespace)

2. Usage of Module

Creation

A python module is just a python file.

Import

import and from

Import Happen Only Once

import and from Are Assignments

Module Search Path

Use

3. Move on to Packages

Ⅲ. Scope (Namespace)

TODO