腾讯云
开发者社区
文档
建议反馈
控制台
登录/注册
首页
学习
活动
专区
圈层
工具
MCP广场
文章/答案/技术大牛
搜索
搜索
关闭
发布
文章
问答
(9999+)
视频
沙龙
1
回答
Python
-
Decorator
on
built-in
class
‘
method
?
我知道我可以在函数定义过程中对自定义函数应用装饰器,如下所示def foo():现在我想在下面的__call__方法上应用一个自制的装饰器。spline_obj = RectBivariateSpline(x, y, z)这个函数不是我定义的。我应该把我的@mydecorator放在哪里?
浏览 7
提问于2017-06-23
得票数 0
回答已采纳
1
回答
Django中基于类视图上带有参数的函数修饰器
、
我想实现这样的目标 @
method
_
decorator
(mydecorator, some_parameters) def dispatch(self
浏览 5
提问于2015-01-09
得票数 20
回答已采纳
2
回答
在方法的开始和结束时做一些事情
、
、
下面是我试图做的一个简化版本: def __init__(self): def func_1(self
浏览 3
提问于2017-05-13
得票数 13
回答已采纳
1
回答
动态分配子类相关装饰器
、
、
class
cls_with_basic_
method
: #if...exec("@decoratorB") #...return arg
浏览 4
提问于2015-05-20
得票数 1
回答已采纳
2
回答
Python
-将类作为参数传递给该类中的方法修饰器?
、
我想做以下几件事: def first_
method
(self): def second_
method
(self): print "I'm the second
method
!"或者,如果我只是传递装潢器,绑定
浏览 6
提问于2017-10-02
得票数 3
回答已采纳
2
回答
Python
装饰器和装饰器模式有什么区别?
、
、
return wrapped(string.upper()) def wrap(instance,'.join(string.split(' ')) @
method
_
decorator
#
Python
decorator
at run t
浏览 4
提问于2011-11-30
得票数 30
回答已采纳
2
回答
从装饰器中获取
Python
函数所属的类
、
、
、
、
__
class
__.__name__ #WHERE DO I GET THIS
浏览 0
提问于2011-10-07
得票数 8
回答已采纳
4
回答
Python
:我想在不将属性类型更改为FunctionType的情况下修饰一个FunctionType属性
、
、
我希望在不将类型(TestObject)更改为FunctionType的情况下实现以下功能: def speak(self): @functools.wraps(func) testObject = TestCla
浏览 6
提问于2016-02-29
得票数 2
回答已采纳
2
回答
__
class
__?
下面是mother_and_child_in_same_file_
decorator
.py模块:setattr( <
class
'mother_and_child_in_same_file_
decorator<
浏览 0
提问于2018-03-15
得票数 0
2
回答
是否有办法在继承期间持久化装饰师?
、
、
如果使用装饰师是正确和可能的选择,它将如下所示: def real_
decorator
(function): if not type(result) == returntype: else: retu
浏览 4
提问于2019-12-23
得票数 5
回答已采纳
1
回答
Cython不适用于带有参数的双装饰器。有解决办法吗?
、
、
、
我在编写
python
代码时遇到了问题。我试着复制我所得到的错误的最简单的例子。
class
some_
class
(): pass @staticmethod@some_
decorator
_with_arg(1) return a print(some_
class
().some_
metho
浏览 0
提问于2019-05-10
得票数 2
回答已采纳
1
回答
Python
打印"<
built-in
method
... object“而不是list
、
# outputs "<
built-in
method
reverse of list object at 0x107eeeec8>"
浏览 1
提问于2016-10-12
得票数 5
回答已采纳
1
回答
父类中定义的继承装饰器
、
、
pass def
method
_1(self): @
decorator
return 1 @
decorator
return
class
B(A): def
me
浏览 1
提问于2015-04-12
得票数 0
2
回答
如何重写
Python
中的修饰方法?
、
假设我想扩展下面的
Python
类,其中包括一个我不太了解的装饰器: @some_
decorator
def some_
method
(self):我是否应该装饰被覆盖的方法?换句话说,我能安全地做到: def some_
method
(self): su
浏览 4
提问于2015-12-10
得票数 8
回答已采纳
2
回答
我不能让私有类装饰器工作
、
、
click_ImportToDB() missing 1 required positional argument: 'self' 如果你能看看下面这些,我已经删减了很多,让我知道我做错了什么,那就太好了:
class
frmApplication(tk.Frame): def __init
浏览 17
提问于2020-06-30
得票数 0
1
回答
正则匹配类方法的动态修饰器
、
、
、
、
这种情况导致如下情况: @
decorator
super().service_
method
1() def service_
method
2(self): super().service_
method
2()(deco=
decorator
1, regex=
浏览 3
提问于2020-12-30
得票数 1
4
回答
装潢工场返灯台
、
def
decorator
(arg2): return
decorator
=
decorator
_factory("r") pass@my_
decorator
_instance('
deco
浏览 2
提问于2022-04-06
得票数 2
回答已采纳
1
回答
对蟒蛇装潢方法的反思
、
、
、
我需要对
python
2.7中的修饰方法做一些反思。通常我使用getattr(my_module, 'my_
method
'),但下面的情况返回我的装饰器的外部函数。在my_module.py中 def outer(): return outer@my_
decorator
pass>>>
浏览 3
提问于2015-08-27
得票数 1
回答已采纳
9
回答
将装饰器附加到类中的所有函数
、
、
、
、
我真的不需要这样做,但我只是想知道,是否有一种方法可以将装饰器绑定到类中的所有函数,而不是显式地为每个函数声明它。
浏览 6
提问于2010-08-12
得票数 67
回答已采纳
2
回答
在装饰器中使用局部时自我丢失
、
、
请参阅代码示例: def __init__(self): def __init__(self): @
decor
浏览 2
提问于2019-12-20
得票数 3
回答已采纳
点击加载更多
相关
资讯
Python Magic Method
python decorator 小记
好家伙,Python自定义接口,玩得这么花
Python装饰器decorator的简易教程
Python入门-类class
热门
标签
更多标签
云服务器
对象存储
ICP备案
云点播
实时音视频
活动推荐
运营活动
广告
关闭
领券