[Python-Dev] PEP 340: Breaking out.
Aahz
aahz at pythoncraft.com
Wed May 4 22:52:27 CEST 2005
On Wed, May 04, 2005, Paul Moore wrote:
>
> Yes, that'd do. I can't say I think it would be common, but it's a
> valid case. And the workaround is the usual messy flag variable:
>
> for name in filenames:
> found = False
> opening(name) as f:
> if f.read(2) == 0xFEB0: found = True
> if found: break
My standard workaround is using exceptions, but I'm not sure how that
interacts with a block:
try:
for name in filenames:
with opened(name) as f:
if f.read(2) == 0xFEB0:
raise Found
except Found:
pass
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"It's 106 miles to Chicago. We have a full tank of gas, a half-pack of
cigarettes, it's dark, and we're wearing sunglasses." "Hit it."
More information about the Python-Dev
mailing list