[python-uk] Tell us what you did with Python this year....

Michael Foord mfoord at python.org
Wed Dec 22 18:19:14 CET 2010


On 21/12/2010 18:28, Floris Bruynooghe wrote:
> On 21 December 2010 18:09, Michael Foord<fuzzyman at voidspace.org.uk>  wrote:
>>
>> On 21 December 2010 14:56, Jonathan Hartley<tartley at tartley.com>  wrote:
>>> On 21/12/2010 14:45, Michael Foord wrote:
>>>> my favourites being contextlib.ContextDecorator
>>> I didn't know that had your fingerprints on it! Nice one - I love this and
>>> use it all the time.
>> It came out of the pattern used in mock where patch (and other decorators)
>> also work as context managers. This was first implemented at Resolver
>> Systems... (I think it was Tom's idea.)
> Heh neat that has made it into the stdlib, even neater that it's used
> in contextlib.contextmanager by default.  I had no idea!  Though
> rather disappointing that it is no longer a cute hack to impress
> people with ;-)
>
> FWIW I'd first heard of it from Dave Beazley's blog, I guess it got
> invented in several places at the same time which must be a good sign
> too.
>
I think there was similar code in django and also py.test (making APIs 
that works as both context managers and decorators) - the fact that it 
was an established pattern than several people had found useful already 
is why we added it to the standard library. :-)

Michael



> Regards
> Floris
>
>


-- 
http://www.voidspace.org.uk/

May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing http://www.sqlite.org/different.html



More information about the python-uk mailing list