Re: Decorators and how they relate to Python - A little insight please!

2006-10-21 Thread [EMAIL PROTECTED]
Jerry wrote: > Thanks to everyone that resonded. I will have to spend some time > reading the information that you've provided. > > To Fredrik, unfortunately yes. I saw the examples, but couldn't get my > head wrapped around their purpose. You're probably looking at the newfangled @decorator syn

Re: Decorators and how they relate to Python - A little insight please!

2006-10-21 Thread Fuzzyman
Fredrik Lundh wrote: > Jerry wrote: > > > even though I've read the PEP > > even the examples section? > > http://www.python.org/dev/peps/pep-0318/#examples > The second example of which shows : Define a class with a singleton instance. Note that once the class disappears enterprising progr

Re: Decorators and how they relate to Python - A little insight please!

2006-10-21 Thread Bruno Desthuilliers
Jerry a écrit : > Thanks to everyone that resonded. I will have to spend some time > reading the information that you've provided. > > To Fredrik, unfortunately yes. I saw the examples, but couldn't get my > head wrapped around their purpose. Perhaps it's due to the fact that > my only experien

Re: Decorators and how they relate to Python - A little insight please!

2006-10-20 Thread Jerry
Thanks to everyone that resonded. I will have to spend some time reading the information that you've provided. To Fredrik, unfortunately yes. I saw the examples, but couldn't get my head wrapped around their purpose. Perhaps it's due to the fact that my only experience with programming is PHP,

Re: Decorators and how they relate to Python - A little insight please!

2006-10-19 Thread Gabriel Genellina
At Friday 20/10/2006 02:38, [EMAIL PROTECTED] wrote: it's handy for doing things like validation of parameter and return types. Like... @accepts(int,int) @returns(int) def add(a,b): return a+b So, it's handy for converting Python into another language :) -- Gabriel Genellina Softlab SRL

Re: Decorators and how they relate to Python - A little insight please!

2006-10-19 Thread Fredrik Lundh
Jerry wrote: > even though I've read the PEP even the examples section? http://www.python.org/dev/peps/pep-0318/#examples if you want more examples, see the cookbook http://www.google.com/search?q=+site%3Aaspn.activestate.com+decorator+cookbook -- http://mail.python.org/mailman/listin

Re: Decorators and how they relate to Python - A little insight please!

2006-10-19 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > it's handy for doing things like validation of parameter and return > types. Like... > > @accepts(int,int) > @returns(int) > def add(a,b): > return a+b using Python decorators to turn Python into something that's not Python doesn't seem very handy to me, though.

Re: Decorators and how they relate to Python - A little insight please!

2006-10-19 Thread [EMAIL PROTECTED]
it's handy for doing things like validation of parameter and return types. Like... @accepts(int,int) @returns(int) def add(a,b): return a+b On Oct 19, 2:04 pm, "Jerry" <[EMAIL PROTECTED]> wrote: > I have just started to do some semi-serious programming (not one-off > specialized scripts) and

Re: Decorators and how they relate to Python - A little insight please!

2006-10-19 Thread johnzenger
When you want to repeatedly apply a certain ALGORITHM to arbitrary sets of DATA, you write a FUNCTION. When you want to add a certain BEHAVIOR to arbitrary sets of FUNCTIONS, you write a DECORATOR. An excellent use of decorators is in Django, the web programming framework. Django keeps track of

Re: Decorators and how they relate to Python - A little insight please!

2006-10-19 Thread Gabriel Genellina
At Thursday 19/10/2006 15:04, Jerry wrote: Now I've come accross decorators and even though I've read the PEP and a little in the documentation, I just don't get what they are or what problem they are trying to solve. Can anyone please point me to a general discussion of decorators (preferrably

Decorators and how they relate to Python - A little insight please!

2006-10-19 Thread Jerry
I have just started to do some semi-serious programming (not one-off specialized scripts) and am loving Python. I just seem to get most of the concepts, the structure, and the classes (something I struggled with before in other languages). I've seen many concepts on the web (i.e. stacks, queues,