Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #57816
| Path | csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <js@globe.de> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'assignment': 0.07; 'debugging': 0.07; 'debugging.': 0.09; 'decorator': 0.09; 'statements': 0.09; 'url:github': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; 'wrote': 0.14; "wouldn't": 0.14; 'ast': 0.16; 'foo()': 0.16; 'foo():': 0.16; 'inserting': 0.16; 'nodes': 0.16; 'received:10.50': 0.16; 'rewriting': 0.16; 'think?': 0.16; 'threads.': 0.16; 'too).': 0.16; 'wrote:': 0.18; 'trying': 0.19; '(but': 0.19; 'gmbh': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'questions:': 0.24; 'replace': 0.24; 'helpful': 0.24; 'people,': 0.24; 'looks': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; "i've": 0.25; 'holds': 0.26; 'code:': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'statement': 0.30; 'code': 0.31; 'object.': 0.31; 'something': 0.35; 'but': 0.35; 'returning': 0.36; 'two': 0.37; 'received:10': 0.37; 'being': 0.38; 'called': 0.40; 'remove': 0.60; 'deleting': 0.60; 'removing': 0.60; 'new': 0.61; 'more': 0.64; 'different': 0.65; '144': 0.84; '260': 0.84; 'nice,': 0.84; 'to:none': 0.92; 'imagine': 0.93 |
| X-Virus-Scanned | Debian amavisd-new at ispconfig-mx01-ha03.globe.de |
| Date | Mon, 28 Oct 2013 13:43:38 +0100 |
| From | Schneider <js@globe.de> |
| Organization | GLOBE Development GmbH |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130804 Thunderbird/17.0.8 |
| MIME-Version | 1.0 |
| CC | python-list@python.org |
| Subject | Re: Debugging decorator |
| References | <CAFEUn8YwMwB6m9LGqsXK8iijK_DRnwv88Xxp8VP_x=Hq2TUnhQ@mail.gmail.com> |
| In-Reply-To | <CAFEUn8YwMwB6m9LGqsXK8iijK_DRnwv88Xxp8VP_x=Hq2TUnhQ@mail.gmail.com> |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 8bit |
| 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.1697.1382964688.18130.python-list@python.org> (permalink) |
| Lines | 79 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1382964688 news.xs4all.nl 15994 [2001:888:2000:d::a6]:57528 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:57816 |
Show key headers only | View raw
On 10/26/2013 01:55 AM, Yaşar Arabacı wrote:
> Hi people,
>
> I wrote this decorator: https://gist.github.com/yasar11732/7163528
>
> When this code executes:
>
> @debugging
> def myfunc(a, b, c, d = 48):
> a = 129
> return a + b
>
> print myfunc(12,15,17)
>
> This is printed:
>
> function myfunc called
> a 12
> c 17
> b 15
> d 48
> assigned new value to a: 129
> returning 144
> 144
>
> I think I can be used instead of inserting and deleting print
> statements when trying to see what is
> passed to a function and what is assingned to what etc. I think it can
> be helpful during debugging.
>
> It works by rewriting ast of the function and inserting print nodes in it.
>
> What do you think?
>
>
Looks very nice, but I've three questions:
1. What happens, if a function has more then one decorator? Wouldn't it
be better to
just remove the debugging decorator instead of removing all decorators?
2. In the case of an assignment (but holds for the return statement too).
think about the following code:
a = 0
@debugging
def foo():
a = a + 1
def bar():
#assign something else to a
Imagine foo() and bar() being called in two different threads. Wouldn't
it be better
to replace a = a + 1 by
|global_debugging_lock_objekt.acquire()|
a = a + 1
print "assigned new value to a, %r", a
|global_debugging_lock_objekt.release()|
for some global lock object.
3. What happens in the case of a += 1?
bg,
Johannes
--
GLOBE Development GmbH
Königsberger Strasse 260
48157 MünsterGLOBE Development GmbH
Königsberger Strasse 260
48157 Münster
0251/5205 390
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Debugging decorator Schneider <js@globe.de> - 2013-10-28 13:43 +0100
csiph-web