Omgili - forum search, search forums  
  

Discussions about use a decorator

Displaying 1 - 10 out of 65,288 discussions.  
RSS Feed Options
Time Frame: (Any time)   Minimum number of replies: (2)   Minimum number of discussing users: (0)
  |  

Page: 1   2   3   4   5   6   7   8   9   10  
Keep this page open to be updated with the newest discussions automatically.
Can anybody explain why the name "Decorator" was chosen for the functionality conveyed by the Decorator design pattern? I've always found that name fairly misleading, because decorator and marking interface sound very similar to me in their purpose. However...
Started by on , 5 posts by 5 people.  
I believe that the origin of the term comes from the example use of DECORATOR (and presumably the application from....
A decorator into the base class.
Hey, leave it to geeks to make up names.
The object with the new functionality.
I'm excited to see the latest version of the decorator python module (3.0). It looks a lot cleaner (e.g. the syntax is more sugary than ever) than previous iterations. However, it seems to have lousy support (e.g. "sour" syntax, to horribly stretch the...
Started by on , 3 posts by 3 people.  
(Anything can be solved by another level of indirection...) from decorator import decorator def substitute_args(arg_sub_dict): @decorator def wrapper(fun, arg....
In this case, you need to make your function return the decorator.
This question was asked already here , but rather than answering the specific question, descriptions of how the decorator pattern works were given instead. I'd like to ask it again because the answer is not immediately evident to me just by reading how...
Started by on , 3 posts by 3 people.  
Using the abstract decorator implementation reduces....
Using decorators based on the abstract decorator class, you how this explodes as the number of possible combinations increases.
Your Beverage with milk and nutmeg.
Ask your Facebook Friends
I am going over my design patterns, and one pattern I have yet to seriously use in my coding is the Decorator Pattern. I understand the pattern, but what I would love to know are some good concrete examples of times in the real world that the decorator...
Started by on , 6 posts by 6 people.  
I've recently ....
Zend Framework uses the decorator for form elements Some more info: http://framework.zend.com/manual/en/zend.form.decorators.html The decorator pattern is used a lot with streams: you can wrap compression.
I just recently really truly groked dependency injection and the wonder of the Decorator design pattern and am using it all over the place. As wonderful as it is however, one thing that I've been having difficulty with is naming my decorator classes so...
Started by on , 5 posts by 5 people.  
Name the decorator class/function after what it does the decorator....
Then it's clearer and easier to include the pattern name in the class, in this case using Decorator as a suffix this belongs in documentation if anywhere.
I'm just reading up on the Chain of Responsibility pattern and I'm having trouble imagining a scenario when I would prefer its use over that of decorator . What do you think? Does CoR have a niche use?
Started by on , 7 posts by 7 people.  
Filters may or maynot handle a specific request but adding a decorator....
Not in a general enhancement form as the decorator does.
Well I can think of 2.
I'd say that a Chain of Responsibility is a particular form of Decorator .
My previous understanding of the decorator pattern was that you inherit Window with WindowDecorator , then in the overridden methods, do some additional work before calling the Window 's implementation of said methods. Similar to the following: public...
Started by on , 5 posts by 5 people.  
In order to use it most effectively } } public class LockableWindow // Decorator....
Adding buffering to a stream) in a way that's transparent to the caller .
The point of the Decorator pattern is to enhance an object with some functionality (e.g.
I have a decorator: from functools import wraps def d(f): @wraps(f) def wrapper(*args,**kwargs): print 'Calling func' return f(*args,**kwargs) return wrapper And I want to prevent it from decorating the same function twice, e.g prevent things such as:...
Started by on , 5 posts by 5 people.  
If there is a decorator....
There is a risk of a conflict if multiple decorators decide to use.
See below, all that is changed is two lines at top of d()'s def def d(f the information in the function itself .
Code to use is co_name .
I have been trying to create a decorator that can be used with both functions and methods in python. This on it's own is not that hard, but when creating a decorator that takes arguments, it seems to be. class methods(object): def __init__(self, *_methods...
Started by on , 5 posts by 5 people.  
Maybe you can better explain one toy use you'd want for your decorator, so we can__ to use your decorator on the Bound Method, you could pass a flag telling it if it's being used to use the same ....
Thereof).
Is there any way of writing a decorator such that the following would work? assert 'z' not in globals() @my_decorator def func(x, y): print z EDIT: moved from anwser In answer to hop's "why?": syntax sugar / DRY. It's not about caching, it's about calculating...
Started by on , 9 posts by 9 people.  
Something like: import types def my_decorator(fn): def decorated(*args,**kw): my_globals={} my_globals) return call_fn(*args,**kw) return decorated @my_decorator def func(x, y): print z func(0,1 declare z as global....
Temporarily.
Page: 1   2   3   4   5   6   7   8   9   10  
More Information


Forum Search About Omgili Help Plugins Forum/Board Owners Privacy

i
In Title
In Topic
In Reply
Exclude
Boost