[Python-Dev] Proposed tweaks to functools.wraps

Raymond Hettinger raymond.hettinger at gmail.com
Thu Aug 12 01:27:26 CEST 2010


On Aug 11, 2010, at 3:28 PM, Benjamin Peterson wrote:

> 2010/8/11 Raymond Hettinger <raymond.hettinger at gmail.com>:
>> 
>> On Aug 11, 2010, at 2:37 PM, Terry Reedy wrote:
>> 
>>> On 8/11/2010 3:16 PM, Raymond Hettinger wrote:
>>> 
>>>> The ability to introspect is basic to Python's design.
>>>> Objects know their class, functions know their code objects,
>>>> bound methods know both their underlying function,
>>>> classes know their own class dictionary, etc.
>>> 
>>> Should iterators know their iterable when there is one?
>>> 
>>> There is or was a request for this on python-list, I believe, a few days ago. I suggested bad idea because
>>> a) iterator requirement is intentially minimal
>>> b) not all iterators have underlying object
>>> c) OP wanted to mutate underlying object (list) while iterating
>>> I did give a my_iter class that would do what OP wanted.
>> 
>> I agree with your assessment.
>> Also an iterator is a protocol, not a single class.
> 
> As is decoration...

This isn't proposed for decoration in general,
just for wraps().  In that respect, it is very much
like bound methods or other things that introspect.

The length of the this thread is surprising.
It is a rather basic piece of functionality
with no real downside.


Raymond




More information about the Python-Dev mailing list