We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a8af392 commit 652b31bCopy full SHA for 652b31b
Readme.md
@@ -453,6 +453,25 @@ class MyClass:
453
...
454
```
455
456
+### 4 import方法
457
+
458
+作为python的模块是天然的单例模式
459
460
+```python
461
+# mysingleton.py
462
+class My_Singleton(object):
463
+ def foo(self):
464
+ pass
465
466
+my_singleton = My_Singleton()
467
468
+# to use
469
+from mysingleton import my_singleton
470
471
+my_singleton.foo()
472
473
+```
474
475
## 17 Python中的作用域
476
477
Python 中,一个变量的作用域总是由在代码中被赋值的地方所决定的。
0 commit comments