Re: How can a function find the function that called it?

2010-12-25 Thread DevPlayer
> Original Poster > I thought I'd implement it as a subclass of collections.OrderedDict > that prohibits all modifications to the dictionary after it has > been initialized. I thought the __new__() method was for customizing how objects where instantated. Where in __new__() you would get an object

Re: How can a function find the function that called it?

2010-12-24 Thread Mark Wooding
kj writes: > But OrderedDict's functionality *requires* that its __init__ be > run, and this __init__, in turn, does part of its initialization > by calling the update method. > > Therefore, the update method of the new subclass needs to be able > to identify the calling function in order to make

Re: How can a function find the function that called it?

2010-12-24 Thread kj
In Daniel Urban writes: >On Fri, Dec 24, 2010 at 17:24, kj wrote: >> (BTW, I don't understand why inspect doesn't provide something as >> basic as the *class* that the method belongs to, whenever applicable. >> I imagine there's a good reason for this coyness, but I can't figure >> it out.) >

Re: [Python] How can a function find the function that called it?

2010-12-24 Thread John Nagle
On 12/24/2010 8:51 AM, Chris Gonnerman wrote: On 12/24/2010 10:24 AM, kj wrote: I want to implement a frozen and ordered dict. I thought I'd implement it as a subclass of collections.OrderedDict that prohibits all modifications to the dictionary after it has been initialized. That's actua

Re: How can a function find the function that called it?

2010-12-24 Thread Daniel Urban
On Fri, Dec 24, 2010 at 17:24, kj wrote: > (BTW, I don't understand why inspect doesn't provide something as > basic as the *class* that the method belongs to, whenever applicable. > I imagine there's a good reason for this coyness, but I can't figure > it out.) One function object can "belong to

Re: How can a function find the function that called it?

2010-12-24 Thread ChasBrown
On Dec 24, 8:24 am, kj wrote: > I want to implement a frozen and ordered dict. > > I thought I'd implement it as a subclass of collections.OrderedDict > that prohibits all modifications to the dictionary after it has > been initialized. > > In particular, calling this frozen subclass's update meth

Re: [Python] How can a function find the function that called it?

2010-12-24 Thread Chris Gonnerman
On 12/24/2010 10:24 AM, kj wrote: I want to implement a frozen and ordered dict. I thought I'd implement it as a subclass of collections.OrderedDict that prohibits all modifications to the dictionary after it has been initialized. In particular, calling this frozen subclass's update method shou

How can a function find the function that called it?

2010-12-24 Thread kj
I want to implement a frozen and ordered dict. I thought I'd implement it as a subclass of collections.OrderedDict that prohibits all modifications to the dictionary after it has been initialized. In particular, calling this frozen subclass's update method should, in general, trigger an exce