Eric Nieuwland wrote:

> This is linear. No looping whatsoever. And easily translated to a 
> simple language construct and a protocol:
> 
> class resource(object):
>       def __init__(self,...):
>               # store resource parameters
>       def __acquire__(self):
>               # whatever it takes to grab the resource
>       def __release__(self):
>               # free the resource


I wanted to see what the examples in PEP340 would look like written with 
standard class's using object inheritance and overriding to define
resource managers.  If anyone's interested I can post it.

My block class is non-looping as I found in most cases looping isn't 
required, and looping complicates things because you have to pass around 
a loop expression due to not all loops will want to behave that same way.

The solution was to put the loop in the body method and call a 
repeat_body method (the repeated body section) which is added to the 
class when needed.

Ron_Adam


_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to