[Python-Dev] PEP 340: Breaking out.
Ron Adam
rrr at ronadam.com
Thu May 5 18:48:29 CEST 2005
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
More information about the Python-Dev
mailing list