Omgili - forum search, search forums  
  

Discussions about decor

Displaying 1 - 10 out of 80,330 discussions.  
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.  
A decorator "decorates" an interface by adding extra....
Hey, leave it to geeks to make up names.
In essence, you are "decorating" the object with the new functionality.
Because you are adding new functionality to an existing object .
Why can decorator not decorate a staticmethod or a classmethod? from decorator import decorator @decorator def print_function_name(function, *args): print '%s was called.' % function.func_name return function(*args) class My_class(object): @print_function...
Started by on , 3 posts by 3 people.  
Is this what you wanted? def print_function_name(function): def wrapper(*args): print('%s was called.' % function.__name__) return function(*args) return wrapper class My_class(object): @classmethod @print_function_name def get_dir(cls): return dir(cls... .
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....
For example, say you want your Beverage with milk and nutmeg .
It enables the decoration of the base class independently with various decorators in different combinations without having to derive a class for each possible combination.
Ask your Facebook Friends
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.
When creating decorators for use on class methods, I'm having trouble when the decorator mechanism is a class rather than a function/closure. When the class form is used, my decorator doesn't get treated as a bound method. Generally I prefer to use the...
Started by on , 3 posts by 3 people.  
This how-to guide teaches all you need to know about that!-) Generally (although not always), when a question is that... .
Your WrapperClass needs to be a descriptor (just like a function is!), i.e., supply appropriate special methods __get__ and __set__ .
Hi, I'm writing a decorator for methods that must inspect the parent methods (the methods of the same name in the parents of the class in which I'm decorating). Example (from the fourth example of PEP 318 ): def returns(rtype): def check_returns(f): def...
Started by on , 3 posts by 3 people.  
Class A(object): @returns(int) def compute(self, value): return value * 3 Is the same as saying: class... .
Here I want to reach the class owning the decorated method f You can't because at the point of decoration, no class owns the method f.
Here's an example of what I mean: class MyDecorator(object): def __call__(self, func): # At which point would I be able to access the decorated method's parent class's instance? # In the below example, I would want to access from here: myinstance def ...
Started by on , 4 posts by 4 people.  
Class MyDecorator(object): def __call__(self, func): def wrapper(that, *args, **kwargs): ## you can access the "self" of func here through the "that" parameter ## and hence do whatever you want return func(that, *args, **kwargs) return wrapper Please... .
I'm implementing a decorator pattern in Javascript. I've seen the example here in Wikipedia // Class to be decorated function Coffee() { this.cost = function() { return 1; }; } // Decorator A function Milk(coffee) { this.cost = function() { return coffee...
Started by on , 5 posts by 5 people.  
You are clearly interested in programming, and quite skilled, but be aware that talking about a true anything... .
The decorator is supposed to change the way an object behaves, how it does it is purely a matter of implementation.
It does not matter.
Hi, can one write sth 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._decorator(self) which also fails: Test unknown If would like to temp. change...
Started by on , 3 posts by 3 people.  
Take, for instance, whether or not the code below looks valid: class Test(object): def _decorator(self, foo): foo() def bar(self): pass bar = self._decorator(bar) It, of course, isn't valid since....
What you're wanting to do isn't possible.
How do I nicely write a decorator? In particular issues include: compatibility with other decorators, preserving of signatures, ect. I would like to avoid dependency on the decorator module if possible, but if there were sufficient advantages, then I ...
Started by on , 3 posts by 3 people.  
Print 'Calling ....
Def wrapper(*args, **kwds): ...
@wraps(f) ...
>>> from functools import wraps >>> def my_decorator(f): ...
Directly from the doc.
The signature won't be preserved.
Use functools to preserve the name and doc.
Page: 1   2   3   4   5   6   7   8   9   10  
Related Searches
Decorations    martial arts cake decor    cake decorating sci fi    how to decorate a sheet cake    python decorators property    sailor moon birthday decorations    compiz dont show decoration nvidia    Decorating a ten year old girl's room    design holidays christmas decorations    mad hatter decorating ideas   
More Information


Forum Search About Omgili Help Plugins Forum/Board Owners Privacy

i
In Title
In Topic
In Reply
Exclude
Boost