Omgili - forum search, search forums  
  

Discussions about decor

Displaying 1 - 10 out of 97,732 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.  
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 .
As an example, def get_booking(f=None): print "Calling get_booking Decorator" def wrapper(request, **kwargs): booking = _get_booking_from_session(request) if booking == None: # we don't have a booking in our session. return HttpRedirect('/') else: return...
Started by on , 6 posts by 6 people.  
This is why you see the output from your ....
@foo def bar (): pass is the same thing as def bar (): pass bar = foo(bar) As you can see, foo is being called even though bar has not been called .
I believe python decorators are just syntactic sugar.
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... .
Ask your Facebook Friends
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.
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__ .
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.
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.
I have a rather complex decorator written by someone else. What I want to do is call a decorated version of the function one time based on a descision or call the original function (not decorated) another time. Is this possible?
Started by on , 3 posts by 3 people.  
Perhaps a sift through some documentation might....
The @ syntax is totally optional.
With: decorator(original_function)() Without: original_function() A decorator is just a function which takes a function as an argument and returns another one.
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