decorator Questions

3

Solved

I wanted to print the source code for my_func, that is wrapped by my_decorator: import inspect from functools import wraps def my_decorator(some_function): @wraps(some_function) def wrapper(): ...
Headrest asked 19/4, 2017 at 21:28

24

Solved

I have a problem with the transfer of the variable insurance_mode by the decorator. I would do it by the following decorator statement: @execute_complete_reservation(True) def test_booking_gta_obje...
Straka asked 8/5, 2011 at 17:40

4

Solved

I am trying to create a class than can run a separate process to go do some work that takes a long time, launch a bunch of these from a main module and then wait for them all to finish. I want to l...
Samarasamarang asked 5/1, 2013 at 7:10

5

Solved

I'm reaching back to my CLOS (Common Lisp Object System) days for this abstract question. I'm augmenting the question to clarify: It appears to me that a Python decorator is sort of like an "ar...
Exserviceman asked 8/9, 2010 at 22:4

4

Solved

I've been playing around with a timing decorator for my pylons app to provide on the fly timing info for specific functions. I've done this by creating a decorator & simply attaching it to any ...
Lauder asked 23/8, 2010 at 8:6

6

I have a module which decorates some key functions with custom decorators. Debugging these functions with pdb often is a bit of a pain, because every time I step into a decorated function I first...
Xylene asked 2/5, 2012 at 11:44

4

Solved

As per manual, functools partial() is 'used for partial function application which “freezes” some portion of a function’s arguments and/or keywords resulting in a new object with a simplified signa...
Davedaveda asked 2/3, 2020 at 20:59

4

Solved

I am trying to build a control structure in a class method that takes a function as input and has different behaviors if a function is decorated or not. Any ideas on how you would go about building...
Barbour asked 29/7, 2021 at 23:40

3

Solved

How Chain of Responsibility Pattern Differs from Decorator Pattern..?
Gutsy asked 15/9, 2010 at 19:49

2

Solved

I want to, for debugging purposes, print out something pertaining to each and every line executed in a python method. For example if there was some assignment in the line, i want to print what va...
Merrymaker asked 23/8, 2015 at 5:19

7

Solved

Is there a way to combine two decorators into one new decorator in python? I realize I can just apply multiple decorators to a function, but I was curious as to whether there's some simple way to ...
Crimson asked 23/3, 2011 at 17:48

22

Solved

How do I make two decorators in Python that would do the following? @make_bold @make_italic def say(): return "Hello" Calling say() should return: "<b><i>Hello</i&gt...
Owl asked 11/4, 2009 at 7:5

6

Solved

I have written a decorator which logs the arguments used to call a particular function or method. As shown below, it works well except that the line number reported in the logRecord is the line num...
Cauley asked 7/9, 2015 at 17:46

14

Solved

Can one write something like: class Test(object): def _decorator(self, foo): foo() @self._decorator def bar(self): pass This fails: self in @self is unknown I also tried: @Test._decorato...
Laws asked 11/8, 2009 at 23:1

6

Solved

Are there ways to decorate functions or methods in C++ like in python style? @decorator def decorated(self, *args, **kwargs): pass Using macros for example: DECORATE(decorator_method) int decorat...
Hassle asked 6/6, 2015 at 5:53

5

Is there a way to inject a dependency into a decorator factory, using Angular's DI? Let's take the following code as a simplified example: @Component({ selector: 'hello-component', template: '&l...
Adamis asked 19/6, 2016 at 11:18

4

Solved

I want a decorator that would add the decorated function to list, like this : class My_Class(object): def __init__(self): self.list=[] @decorator def my_function(self) print 'Hi' I expect...
Peal asked 4/12, 2011 at 14:10

1

Solved

I try to get into TypeScript by writing TS based Lit Elements, refactoring a very small project of mine. However it starts to get frustrating since I don't see what's wrong with this code since it'...
Dorcy asked 18/8, 2023 at 15:23

5

Solved

I have a python class which has several properties. I want to implement a method which will return some properties as a dict. I want to mark the properties with a decorator. Here's an example: clas...
Unsheathe asked 29/6, 2023 at 15:32

2

Solved

I implemented a decorator in the same way as here How to make a python decorator function in Flask with arguments (for authorization) but problem still unsolved... I have this function with decora...
Souza asked 18/12, 2012 at 11:9

2

I created a new Spring-boot project and wanted to use Thymeleaf with the LayoutDialect. My pom.xml has following dependencies: <dependencies> <dependency> <groupId>org.springf...
Disulfide asked 7/2, 2015 at 17:20

2

Solved

Why can't I make a class' __call__ method static using the @staticmethod decorator? class Foo(object): @staticmethod def bar(): return 'bar' @staticmethod def __call__(): return '__call__' ...
Throttle asked 7/11, 2014 at 3:32

2

Solved

I am testing the new @admin.register decorator that is a new feature from Django 1.7. I am currently using Django 1.8.2 and Python 3 and happened me the following situation in relation to @admin.re...
Barcellona asked 6/7, 2015 at 0:53

8

I need to mark routines as deprecated, but apparently there's no standard library decorator for deprecation. I am aware of recipes for it and the warnings module, but my question is: why is there n...
Girth asked 29/3, 2010 at 7:14

5

Solved

I am trying to inject a service into a decorator function in which I am creating, this is so I can get the contents that are stored inside of variables. I currently have a basic decorator setup. ...
Ricks asked 5/10, 2018 at 12:14

© 2022 - 2025 — McMap. All rights reserved.