当前位置:网站首页>Give the method of instantiating the object to the new object
Give the method of instantiating the object to the new object
2022-04-23 09:11:00 【A1L__】
The method that instantiates the object Use... For new objects
class SharedKls:
def __setattr__(self, key, value):
if not hasattr(SharedKls, key):
if callable(value): # Can I call
# No addition staticmethod, Default transmission self
value = staticmethod(value)
setattr(SharedKls, key, value)
kls_a = SharedKls()
kls_b = SharedKls()
kls_a.attr_a = 1
def func(self, x):
return x * x
kls_a.method_a = lambda x: x * 3
assert kls_b.method_a(3) == 9
版权声明
本文为[A1L__]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230657490293.html
边栏推荐
- On array replication
- First principle mind map
- [original] use system Text. JSON formats the JSON string
- Brief steps to build a website / application using flash and H5
- Project upload part
- Kettle实验 (三)
- Kettle实验 转换案例
- OpenCV中的图像处理 —— 轮廓入门+轮廓特征
- Non duplicate data values of two MySQL query tables
- Summary of solid problems
猜你喜欢

Failed to download esp32 program, prompting timeout

Applet error: should have URL attribute when using navigateto, redirectto or switchtab

BK3633 规格书

I don't understand time, timestamp and time zone. Look at this article

机器学习(六)——贝叶斯分类器

EmuElec 编译总结

Common errors of VMware building es8

Distributed message oriented middleware framework selection - Digital Architecture Design (7)
![[58] length of the last word [leetcode]](/img/c5/3ba1fe5a81593d9576bb597f0d5f45.png)
[58] length of the last word [leetcode]

Introduction to GUI programming swing
随机推荐
BK3633 规格书
Detailed explanation of delete, truncate and drop principles in MySQL database
Output first order traversal according to second order and middle order traversal (25 points)
Summary of wrong questions 1
Emuelec compilation summary
108. 将有序数组转换为二叉搜索树
Resource packaging dependency tree
Group Backpack
Share the office and improve the settled experience
MYCAT configuration
员工试用期转正申请书(泸州老窖)
108. Convert an ordered array into a binary search tree
Image processing in opencv -- Introduction to contour + contour features
OpenCV中的图像处理 —— 轮廓入门+轮廓特征
kettle实验
小程序报错 :should have url attribute when using navigateTo, redirectTo or switchTab
2021 Li Hongyi's adaptive learning rate of machine learning
Applet error: should have URL attribute when using navigateto, redirectto or switchtab
First principle mind map
Solidity 问题汇总