how to get id(function) for each function in stack?
robert.kern at gmail.com
Sat Jan 7 05:39:28 EST 2012
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 at 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.
"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
More information about the Python-list