Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #18634

Re: how to get id(function) for each function in stack?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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; '(especially': 0.07; 'attribute': 0.07; 'python': 0.08; 'builtin': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'stack,': 0.09; 'stack.': 0.09; 'underlying': 0.09; 'am,': 0.12; 'enigma': 0.16; 'kern': 0.16; 'react': 0.16; 'subject:function': 0.16; 'wrote:': 0.18; '>>>': 0.18; 'ryan': 0.18; 'wrap': 0.18; 'jan': 0.19; '(which': 0.19; 'extension': 0.21; 'header:In-Reply-To:1': 0.22; 'objects,': 0.23; 'there.': 0.24; 'code': 0.25; 'function': 0.27; 'interpret': 0.29; 'problem': 0.29; 'pm,': 0.29; 'kelly': 0.30; 'subject:each': 0.30; 'subject:?': 0.31; 'objects': 0.32; "isn't": 0.33; 'header:User-Agent:1': 0.33; 'header:X-Complaints- To:1': 0.33; 'there': 0.33; 'fri,': 0.34; 'to:addr:python-list': 0.34; 'someone': 0.34; 'lie': 0.34; 'issue': 0.35; 'acceptable': 0.37; 'but': 0.37; 'skip:_ 10': 0.37; 'using': 0.38; 'received:org': 0.38; 'some': 0.38; 'should': 0.39; 'subject:how': 0.39; 'to:addr:python.org': 0.40; 'might': 0.40; 'world': 0.62; 'received:86': 0.63; 'our': 0.64; 'believe': 0.65; '2012': 0.67; 'it)': 0.67; 'informative': 0.73; 'lose': 0.84; '12:17': 0.84; '12:29': 0.84; 'build-in': 0.84; 'case?': 0.84; 'warning.': 0.84; 'eco': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Robert Kern <robert.kern@gmail.com>
Subject Re: how to get id(function) for each function in stack?
Date Sat, 07 Jan 2012 10:39:28 +0000
References <1002d4cd-6cfe-4b79-917f-361a06ffd215@a11g2000vbz.googlegroups.com> <mailman.4490.1325874536.27778.python-list@python.org> <9f8a8fd4-3541-4f9b-a887-3d10524de8f1@t30g2000vbx.googlegroups.com> <CALwzid=wSK6FRGjfe1_O-zVo2g1sAji7a1dVYRnJv6MewmbNoA@mail.gmail.com> <je82v2$ok9$2@dough.gmane.org>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host cpc24-cmbg15-2-0-cust204.5-4.cable.virginmedia.com
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:8.0) Gecko/20111105 Thunderbird/8.0
In-Reply-To <je82v2$ok9$2@dough.gmane.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4504.1325932780.27778.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1325932780 news.xs4all.nl 6877 [2001:888:2000:d::a6]:41626
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:18634

Show key headers only | View raw


On 1/7/12 12:17 AM, Lie Ryan wrote:
> On 01/07/2012 06:50 AM, Ian Kelly wrote:
>> On Fri, Jan 6, 2012 at 12:29 PM, dmitrey<dmitrey15@gmail.com> wrote:
>>> Python build-in function sum() has no attribute func_code, what should
>>> I do in the case?
>>
>> Built-in functions and C extension functions have no code objects, and
>> for that reason they also do not exist in the stack. There is no way
>> to find sum() in the Python stack, because it isn't there.
>
> a practical solution to this issue is to wrap the C functions in Python
> functions. You lose some speed but that might be an acceptable tradeoff in some
> situations (especially if you're only wrapping when debugging).

His problem is that he wants to find out when someone is using the builtin sum() 
on his objects (which apparently don't react well to it) and give an informative 
warning. __builtin__.sum() is not under his control, fortunately.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

how to get id(function) for each function in stack? dmitrey <dmitrey15@gmail.com> - 2012-01-06 10:02 -0800
  Re: how to get id(function) for each function in stack? Ian Kelly <ian.g.kelly@gmail.com> - 2012-01-06 11:28 -0700
    Re: how to get id(function) for each function in stack? dmitrey <dmitrey15@gmail.com> - 2012-01-06 11:29 -0800
      Re: how to get id(function) for each function in stack? Ian Kelly <ian.g.kelly@gmail.com> - 2012-01-06 12:50 -0700
      Re: how to get id(function) for each function in stack? Dave Angel <d@davea.name> - 2012-01-06 14:56 -0500
      Re: how to get id(function) for each function in stack? Ian Kelly <ian.g.kelly@gmail.com> - 2012-01-06 13:37 -0700
      Re: how to get id(function) for each function in stack? Lie Ryan <lie.1296@gmail.com> - 2012-01-07 11:17 +1100
      Re: how to get id(function) for each function in stack? Robert Kern <robert.kern@gmail.com> - 2012-01-07 10:39 +0000
  Re: how to get id(function) for each function in stack? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-01-07 00:54 +0000

csiph-web