Re: python decorator

2017-02-22 Thread Irmen de Jong
On 22-2-2017 8:39, Argentinian Black ops lll wrote: > Thanks for the quick response...! you saved me a lot of time, thank you! > I don't know if you want/have to use your own custom caching decorator, but are you aware of the lru_cache decorator that's part of the standard library?

Re: python decorator

2017-02-22 Thread Ian Kelly
On Wed, Feb 22, 2017 at 8:16 AM, Pavol Lisy wrote: > Maybe this technique could be reusable (and maybe part of functools?) > > With this decorator: > > def wrap_args(decorator): > def decor_out(*args, **kwargs): > def decor_in(func): >

Re: python decorator

2017-02-22 Thread Pavol Lisy
On 2/22/17, Steve D'Aprano wrote: > On Wed, 22 Feb 2017 08:47 pm, Cecil Westerhof wrote: > >> On Wednesday 22 Feb 2017 08:49 CET, Argentinian Black ops lll wrote: >> >>> *** SOLVED *** >> >> It would be nice if you shared the solution. > > I believe Cameron's post

Re: python decorator

2017-02-22 Thread Steve D'Aprano
On Wed, 22 Feb 2017 08:47 pm, Cecil Westerhof wrote: > On Wednesday 22 Feb 2017 08:49 CET, Argentinian Black ops lll wrote: > >> *** SOLVED *** > > It would be nice if you shared the solution. I believe Cameron's post contains the bones of a solution. Here's my untested solution. def

Re: python decorator

2017-02-22 Thread Cecil Westerhof
On Wednesday 22 Feb 2017 08:49 CET, Argentinian Black ops lll wrote: > *** SOLVED *** It would be nice if you shared the solution. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof -- https://mail.python.org/mailman/listinfo/python-list

Re: python decorator

2017-02-21 Thread Argentinian Black ops lll
*** SOLVED *** -- https://mail.python.org/mailman/listinfo/python-list

Re: python decorator

2017-02-21 Thread Argentinian Black ops lll
Thanks for the quick response...! you saved me a lot of time, thank you! -- https://mail.python.org/mailman/listinfo/python-list

Re: python decorator

2017-02-21 Thread Cameron Simpson
On 21Feb2017 22:44, alfredocabre...@gmail.com wrote: I have a python function and a decorator that works just fine. def fun_cache(function): memo = {} def wrapper(*args): if args in memo: return memo[args] else: rv =

python decorator

2017-02-21 Thread alfredocabrera4
I have a python function and a decorator that works just fine. def fun_cache(function): memo = {} def wrapper(*args): if args in memo: return memo[args] else: rv = function(*args) memo[args] = rv return rv return wrapper

Adding to Python Decorator Library at wiki.python.org

2012-05-30 Thread marctbg
I just created an account to contribute to the wiki.python.org Python Decorator Library Wiki. I added my code titled == Memoize Objects == using the Wiki editor. The preview looked good. Then i submitted it. However, it is not showing up on the Wiki. I could not find contact info

Re: Adding to Python Decorator Library at wiki.python.org

2012-05-30 Thread Steven D'Aprano
On Wed, 30 May 2012 07:51:32 -0700, marctbg wrote: I just created an account to contribute to the wiki.python.org Python Decorator Library Wiki. I added my code titled == Memoize Objects == using the Wiki editor. The preview looked good. Then i submitted it. However, it is not showing up

Python decorator syntax limitations

2010-01-18 Thread Jonathan S
Hi all, The following is what I want to do, but this results in a syntax error: @news_page('template.html').lookup(News, 'news_id', 'news') def view(request, group, news): pass What does work is the equivalent old way of doing decorating: def view(request, group, news): pass view =

Re: Python decorator syntax limitations

2010-01-18 Thread Steve Howell
On Jan 18, 8:44 am, Jonathan S jonathan.slend...@gmail.com wrote: Hi all, The following is what I want to do, but this results in a syntax error: @news_page('template.html').lookup(News, 'news_id', 'news') def view(request, group, news):     pass What does work is the equivalent old way

Re: Python decorator syntax limitations

2010-01-18 Thread Lie Ryan
On 01/19/10 03:44, Jonathan S wrote: Any suggestions? I have my reasons for doing this, (news_page is a class, and __call__ is used to wrap the template.) I'm sure this is a limitation in the syntax, but would parenthesis somewhere help? The restriction[1] is put in there since Guido has a

Re: Python decorator syntax limitations

2010-01-18 Thread Peter Otten
Jonathan S wrote: Hi all, The following is what I want to do, but this results in a syntax error: @news_page('template.html').lookup(News, 'news_id', 'news') def view(request, group, news): pass What does work is the equivalent old way of doing decorating: def

Re: Python decorator syntax limitations

2010-01-18 Thread Aahz
In article 4b54998...@dnews.tpgi.com.au, Lie Ryan lie.1...@gmail.com wrote: If you are sure you can put up a convincing argument for lifting this restriction, and you are willing to put some time arguing, you are welcome to start a thread in the python-dev mailing list. Be sure to read about

Re: Python decorator syntax limitations

2010-01-18 Thread Arnaud Delobelle
a...@pythoncraft.com (Aahz) writes: In article 4b54998...@dnews.tpgi.com.au, Lie Ryan lie.1...@gmail.com wrote: If you are sure you can put up a convincing argument for lifting this restriction, and you are willing to put some time arguing, you are welcome to start a thread in the python-dev

Re: Python decorator syntax limitations

2010-01-18 Thread Jonathan S
Thanks a lot, all of you! This was really helpful. (or at least give me the inspiration I needed to finish it.) I'm sure this is a use case where most other options are less readable than the chain of methods in the decorator. In this use case, I had a lot of Django views to which access

Python decorator article

2006-10-20 Thread gole
Hello, I am writing to point interested readers to a few short articles on decorators: Please find them here: http://muharem.wordpress.com/2006/10/18/3/ Best regards -- Muharem -- http://mail.python.org/mailman/listinfo/python-list