A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-May/053361.html below:

[Python-Dev] PEP 340: Breaking out.

[Python-Dev] PEP 340: Breaking out. [Python-Dev] PEP 340: Breaking out.Reinhold Birkenfeld reinhold-birkenfeld-nospam at wolke7.net
Wed May 4 23:31:53 CEST 2005
Aahz wrote:
> 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

>From a naive point of view, it should definitely work as expected.
>From the PEP point of view, no clue. *hope*

Reinhold

-- 
Mail address is perfectly valid!

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4