python中的Singleton类来自两个单独的python调用

2024-10-05 14:23:34 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个单身的a级

class A:
__metaclass__=Singleton;
#other stuff

然后在test.py中有一个对象,如下所示:

a = A()

如果我从两个不同的命令行执行以下操作:

python test.py #first command line
python test.py #second command line

我会有同样的例子吗?如果不是,有人能解释为什么吗


Tags: 对象命令行pytestlinecommandclassmetaclass