Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Dr Dobbs "with" keyword

Reply
Thread Tools

Dr Dobbs "with" keyword

 
 
Neil Hodgson
Guest
Posts: n/a
 
      04-16-2005
In the March 2005 issue of Dr Dobbs Journal there is an article
"Resource Management in Python" by Oliver Schoenborn. One paragraph
(first new paragraph, page 56) starts "Starting with Python 2.4, a new
type of expression lets you use the keyword /with/". It continues,
mentioning PEP 310 (Reliable Acquisition/Release Pairs) which is at
"Draft" status and unlikely to be accepted with the keyword "with" as
Guido wants to use that for another purpose. The discussion of cyclic
garbage also troubles me but is not an area in which I have much
experience.

While publishing a correction in a future issue would not be very
helpful, adding a correction to online and CD-ROM versions would be. If
anyone understands the technical review process at DDJ, could they give
them a little prod.

Neil
 
Reply With Quote
 
 
 
 
Giovanni Bajo
Guest
Posts: n/a
 
      04-16-2005
Neil Hodgson wrote:

> In the March 2005 issue of Dr Dobbs Journal there is an article
> "Resource Management in Python" by Oliver Schoenborn. One paragraph
> (first new paragraph, page 56) starts "Starting with Python 2.4, a new
> type of expression lets you use the keyword /with/". It continues,
> mentioning PEP 310 (Reliable Acquisition/Release Pairs) which is at
> "Draft" status and unlikely to be accepted with the keyword "with" as
> Guido wants to use that for another purpose.


Whatever keyword is chosen, I hope PEP 310 eventually hit Python, I have been
awaiting it for a long time. I would also like to have a builtin resource()
like this:

def resource(enter_call, exit_call):
class Res(object):
__enter__ = lambda self: enter_call()
__exit__ = lambda self: exit_call()
return Res()

with resource(self.mutex.lock, self.mutex.unlock):
pass

Either that, or "with" could call adapt() implicitly so I can register my
conversion functions.
--
Giovanni Bajo


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dr Dobbs' Python Weekly URL Archive? Steve Holden Python 0 03-05-2009 05:36 AM
[OT] - Dr Dobbs Portal Article (March 01, 2000) 2b|!2b==? C++ 2 01-08-2008 02:27 PM
Dr. Dobbs and other periodicals? Digital Puer Java 5 09-12-2003 02:26 PM
Dr. Dobbs and other periodicals? Digital Puer C Programming 6 09-12-2003 02:26 PM
Dr. Dobbs and other periodicals? Digital Puer C++ 5 09-12-2003 02:26 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57