Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #54599
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'finally:': 0.07; 'decorator': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'try:': 0.09; 'subject:How': 0.10; 'def': 0.12; 'jan': 0.12; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'subject: \n ': 0.16; 'wrote:': 0.18; 'import': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'define': 0.26; 'pass': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply- To:1': 0.27; 'function': 0.29; 'yes.': 0.31; 'file': 0.32; 'class': 0.32; 'skip:_ 10': 0.34; 'no,': 0.35; 'question,': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'subject:can': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'called': 0.40; 'received:173': 0.61; 'subject:have': 0.80; 'received:fios.verizon.net': 0.84; 'subject: . ': 0.84; 'subject:want': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Terry Reedy <tjreedy@udel.edu> |
| Subject | Re: I want to print entry and exit message for functions , i have bunch of such function . How can i do it in decorator. |
| Date | Sun, 22 Sep 2013 16:48:39 -0400 |
| References | <30bf5567-47ff-4b54-acc4-aebb0451e47d@googlegroups.com> <8aaaf0ab-09e0-4772-a906-333572320228@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | pool-173-75-251-66.phlapa.fios.verizon.net |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.0 |
| In-Reply-To | <8aaaf0ab-09e0-4772-a906-333572320228@googlegroups.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.250.1379882939.18130.python-list@python.org> (permalink) |
| Lines | 37 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1379882939 news.xs4all.nl 15997 [2001:888:2000:d::a6]:51548 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:54599 |
Show key headers only | View raw
On 9/22/2013 2:57 PM, bab mis wrote: > def funlog(f): > def g(*args,**kw): > print "enter", f.__name__ > try: > return f(*args, **kw) > finally: > print "exit", f.__name__ > return g > > class Action: > def __init__(self): > pass > > @funlog > def sret(self): > pass > > @funlog > def ping(self): > pass > def verifyerun(self): > pass > > > 1) funlog is called for the last function as well. If this is a question, no, it is not called on verifyerun. > 2) Is it a proper way to define decorator out of class and use it . Yes. It is not an Action methods. If you use it in multiple files, define once in one file and import it. -- Terry Jan Reedy
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
I want to print entry and exit message for functions , i have bunch of such function . How can i do it in decorator. bab mis <babmis307@gmail.com> - 2013-09-20 05:59 -0700
Re: I want to print entry and exit message for functions , i have bunch of such function . How can i do it in decorator. Peter Otten <__peter__@web.de> - 2013-09-20 15:23 +0200
Re: I want to print entry and exit message for functions , i have bunch of such function . How can i do it in decorator. bab mis <babmis307@gmail.com> - 2013-09-22 11:57 -0700
Re: I want to print entry and exit message for functions , i have bunch of such function . How can i do it in decorator. Terry Reedy <tjreedy@udel.edu> - 2013-09-22 16:48 -0400
csiph-web