decorator
Python - How to specify an optional argument for class based decorators?
How would I write a decorator like this.I want to be able to specify the value for max_hits when I call the decorator (or optionally leave it out).[详细]
2023-03-06 10:51 分类:问答How is this called and how can be done ( `function_name.decorator` )?
Really sorry for the extremely stupid title, but if I know what it is, I wouldn\'t write here (: def some_decorator( func ):[详细]
2023-03-06 06:11 分类:问答Decorating method (class methods overloading)
Inspired by Muhammad Alkarouri answer in What are good uses for Python3's "Function Annotations" , I want to do this multimethod for methods, not regular functions. However, when I do th[详细]
2023-03-06 05:51 分类:问答Design for customizable string filter
Suppose I\'ve tons of filenames in my_dir/my_subdir, formatted in a some way: data11_7TeV.00179691.physics_Egamma.merge.NTUP_PHOTON.f360_m796_p541_tid319627_00[详细]
2023-03-06 02:18 分类:问答How do you preserve interfaces when using the decorator pattern?
If the objects being decorated implement different combinations of other interfaces, how do you implement a decorator without losing the extra interface methods?For example, say we have the following[详细]
2023-03-06 01:29 分类:问答How to create abstract properties in python abstract classes?
In the following code, I create a base abstract class Base. I want all the classes that inherit from Base to provide the name property, so I made this property an @abstractmethod.[详细]
2023-03-04 20:29 分类:问答How to decorate an object method?
I need to decorate a object\'s method. It needs to be at runtime because the decorators applied on the object depends on the arguments that the user gave when calling the program (arguments supplied w[详细]
2023-03-04 17:12 分类:问答Decorators with parameters?
I have a problem with the transfer of the variable insurance_mode by the decorator. I would do it by the following decorator statement:[详细]
2023-03-04 16:43 分类:问答MVC with Decorator pattern
In a project im working on we hold a strict MVC structure. Im thinking of adding a decorator pattern to some of the modal windows (tiny popup windows) for those implementations where i whant some extr[详细]
2023-03-03 16:24 分类:问答Django is_staff permission decorator
I am trying to limit access to pages using 2 user levels. Superuser and admin. Super user is a regular Django user with \'is_superuser\' assigned.[详细]
2023-03-02 03:51 分类:问答