单例模式

An object that is the only existing instance of a class,usually not by accident but because the class is designed to prevent creation of more than one instance.There is also a design pattern named Singleton,which is a recipe for coding such classes.

举例来说,None对象就是一个Singleton

即使一个程序中存在多个使用None的地方,None对象在内存中只存在一个实例。

a tuple of one item也是Siingleton,即只有一个元素的元祖也属于Singleton

results matching ""

    No results matching ""