break in a module

Erik Max Francis max at alcyone.com
Thu Jun 16 21:13:06 EDT 2011


Chris Angelico wrote:
> On Fri, Jun 17, 2011 at 9:29 AM, Erik Max Francis <max at alcyone.com> wrote:
>> Chris Angelico wrote:
>>> On Fri, Jun 17, 2011 at 8:07 AM, Erik Max Francis <max at alcyone.com> wrote:
>>>> It's quite consistent on which control structures you can break out of --
>>>> it's the looping ones.
>>> Plus functions.
>> No:
>>
>>>>> def f():
>> ...  break
>> ...
>>  File "<stdin>", line 2
>> SyntaxError: 'break' outside loop
> 
> Yes:
> def f():
>     return
>     print("Won't happen")
> 
> "break out of" doesn't necessarily require the break keyword per se.
> You can abort a function part way, same as you can abort a loop part
> way.

Look back at the context.  I was actually talking about the break keyword.

-- 
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
  San Jose, CA, USA && 37 18 N 121 57 W && AIM/Y!M/Skype erikmaxfrancis
   Human salvation lies in the hands of the creatively maladjusted.
    -- Dr. Martin Luther King, Jr.



More information about the Python-list mailing list