Python
Java
PHP
IOS
Android
Nodejs
JavaScript
Html5
Windows
Ubuntu
Linux
如何使用和应用 JavaScript 装饰器?
我试图了解如何在一段非常简单的代码中使用装饰器 这样我就可以将这个概念应用到我更大的项目中 从 Addy Osmani 的文章中得到启发here https medium com google developers exploring es
nodejs
decorator
ecmascriptnext
如何装饰可调用类的实例?
def decorator fn def wrapper args kwargs print With sour cream and chives return fn args kwargs return wrapper class Pot
python
decorator
带有装饰器和会话的 django 类视图
我正在尝试将一些 django 视图从基于函数的视图转换为基于类的视图 但遇到了一个小问题 我的面向对象有点弱 我认为问题是我已经不知道事情的进展情况 我有一个自定义的登录装饰器 我需要在视图上使用 所以我 首先我有这个例子中的 View
django
Session
class
View
decorator
使用装饰器恢复生成器
让我们有一个类 它的功能有时会失败 但经过一些操作后它就可以完美地工作 现实生活中的例子是 Mysql 查询 它会引发 mysql exceptions OperationalError 2006 MySQL server has gone
python
python3x
decorator
yield
如何获取方法参数名称?
假设有一个函数a method被定义为 def a method arg1 arg2 pass 从 开始a method本身 我如何获取参数名称 例如 作为字符串元组 例如 arg1 arg2 看看inspect http docs pyt
python
decorator
introspection
pythondatamodel
声明静态成员的类装饰器(例如,对于 log4net)?
我正在使用 log4net 我们的代码中有很多这样的内容 public class Foo private static readonly ILog log LogManager GetLogger typeof Foo 一个缺点是 这意味
c
decorator
staticmembers
Flask:为什么 app.route() 装饰器应该总是在最外面?
说吧 我有一个手工制作的 login required装饰器 from functools import wraps def login required decorated function Decorator to check if u
python
Flask
decorator
pythondecorators
getter 和 setter 的 Google 样式指南属性
我对其中的一项建议感到好奇有关属性的 Google Python 风格指南 https google github io styleguide pyguide html Properties 他们在其中给出了以下示例 class Squar
python
properties
decorator
pythondecorators
googlestyleguide
python中装饰器类的解释
在阅读一些 python 模块时 我遇到了这个装饰器类 this decorator lets me use methods as both static and instance methods class omnimethod obje
python
properties
decorator
在Python中使用@staticmethod和全局函数有什么区别?
我读过了 staticmethod 和 classmethod 有什么区别 Python https stackoverflow com questions 136097 what is the difference between sta
python
decorator
检查函数是否被修饰
我正在尝试在类方法中构建一个控制结构 该方法将函数作为输入 并且如果函数被修饰或未修饰 则具有不同的行为 关于如何构建函数的任何想法is decorated其行为如下 def dec fun do decoration def func d
python
python3x
closures
decorator
pythondecorators
如何组合多个 TypeScript 类装饰器?
我有一个类装饰器家族 我在很多类中重复使用它们 与此类似的东西 foo bar baz export class MyClass 由于我在多个类中使用这三个装饰器 我真的很想将其分解为一个装饰器 如下所示 standard export c
typescript
decorator
解析装饰器中的 args 和 kwargs
我有一个需要 args 和 kwargs 的函数 我需要根据 args 和 kwargs 的值在我的装饰器中做一些事情2nd函数中的arg 如下面的代码所示 def workaround func def decorator fn def
python
decorator
如何在责任链中注入下一个处理程序的依赖关系?
在我当前的项目中 我使用了相当多的责任链模式 然而 我发现通过依赖注入配置链有点尴尬 给定这个模型 public interface IChainOfResponsibility IChainOfResponsibility Next ge
c
ASPNETCore
dependencyinjection
decorator
chainofresponsibility
Django自定义装饰器重定向问题
我尝试在 Django 中编写一个自定义装饰器 如果用户未通过该页面登录 我想将用户重定向到自定义登录页面 我已经编写了装饰器并调试了它 虽然如果用户未登录 它可以正常工作 但在用户登录后 它会给出错误 The view APPNAME v
django
redirect
decorator
如何在 TypeScript 中向装饰器添加可选参数?
我想创建一个可以选择接受参数的字段装饰器 该参数应包含以下任意值 无 布尔值或函数 我知道如何做到这一点 但我对结果并不是 100 满意 export class TestClass Required isRequired public t
typescript
decorator
typescript18
Typescript 属性装饰器可以为类设置元数据吗?
在打字稿中 是否可以使用属性装饰器来设置类的元数据 考虑下面的代码 类装饰器的 目标 显然与属性装饰器的 目标 不同 我可以从另一个派生出一个吗 import reflect metadata const MY CLASS DECORATO
typescript
Reflection
metadata
decorator
带选项的 Python 装饰器
我有一个模块 它的函数原型与线程类的原型类似 def do fn argtuple kwargdict priority 0 block False timeout 0 callback None daemon False do stuff
python
arguments
decorator
装饰器可以装饰递归函数吗?
我想看看两种计算斐波那契数列的方法之间的时间成本差异 首先 我创建了一个装饰器 将 输出时间成本 函数添加到函数中 def time cost func def wed n start time time func n stop time
python
python3x
recursion
decorator
是否可以用 login_required 装饰 django url 中的 include(...) ?
我的网站上有一些限制区域 我想为其指定login required装饰师 不过 我想在主 urls py 中的每个包含项中执行一次 而不是包含的 urls py 中的每个单独的 url 执行一次 所以而不是 private urls py
django
URL
functionalprogramming
decorator
«
1
2
3
4
5
6
...10
»